S
S
Sergey Alekseev2018-03-19 09:53:40
React
Sergey Alekseev, 2018-03-19 09:53:40

React Redux, how to limit data loading from redux store?

Good afternoon, such a problem. There is a list of projects, we add a list of works to it. At the backend level, I link jobs to the project and successfully load them, but if I open two projects, their jobs are the same. I use the ComponentWillMount method

componentDidMount() {
    if (this.props.projectId===this.props.works.projectId) {
        this.props.loadWorks(this.props.projectId);
  }

I'm trying to load a project's work by its id. And I check that the project id is equal to the projectId field that I add to works when creating it. But the second field is undefined. What are the solutions?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lonely griffin @Lonely, 2018-03-19
griffin

It's hard to tell from the description, I can only guess.
Your component is mounted once and when you reopen the project, loadWorks is not called to update the work.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question