V
V
Vlad2019-10-16 11:45:57
JavaScript
Vlad, 2019-10-16 11:45:57

How to output / not display data correctly?

good afternoon!
Please tell me how to correctly hide pieces of code if there is no data from the API.
Here is the reducer where the data is processed:

export function queryLog(state = initialState, action): object {
    if (action.type === constants.LOAD_QUERY_LOG_STOP) {
        log = action.queryLog;
    }
    if (action.type === constants.LOAD_COMMENTS_STOP) {
        comments = action.comments;
    }

    let summ = log.concat(comments).map(el => {
        el.date = el.dt_changelog * 1000 || el.datetime * 1000;
        el.type = el.dt_changelog ? 'changelog' : 'comment';
        el.text = el.dt_changelog ? changed : el.text;
        el.author = el.dt_changelog ? el.usr.source : el.author;
        el.status = el.changelog ? ('Статус' in el.changelog ? el.changelog['Статус'].after : ' не назначен') : '';
        return el;
    });

I need to do this:
"If there is no data about "Status" in the api, then the block is not displayed"
5da6d8ba247e5918625419.png

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
vadimMalovaniy, 2019-10-16
@vadimMalovaniy

In React, you write if there is data, you output a block. It is react that is responsible for displaying the data. Redux only stores them.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question