O
O
olegan_092020-02-10 13:57:44
React
olegan_09, 2020-02-10 13:57:44

Why can't display data from internal state when using redux?

My component has its own state, it contains an array of objects. As soon as this array is not empty, it is drawn. and everything worked fine until I needed to legalize it with redux. As I connected it, in a strange way nothing is drawn. The internal state also exists and works fine. I output it to the console before the map function and it is shown, but it does not enter the map. As soon as I disable redux from the component, everything works. but on the next action on the client (in this case, submitting the form), it is already being rendered. For me, this is a very strange behavior that I encountered for the first time. Please tell me how to solve this.

const renderFiles = () => {
    return (
      <div style={{ marginTop: 20 }}>
        <Grid container spacing={1}>
          //здесь выводил в консоль и все есть а ниже уже не работает код
          {files.map(({ fileName, base64 }) => (
            <Grid key={fileName} item>
              <div style={{ width: 90, height: 90, overflow: 'hidden' }}>
                <img
                  style={{ width: '100%', height: '100%', objectFit: 'cover' }}
                  src={base64}
                />
              </div>
            </Grid>
          ))}
        </Grid>
      </div>
    );
  };

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question