Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
no need to write props to the state, it's better to work immediately with this this.props.....number where
this Worker component is needed each time a new one is created, or is it created only once, and then after updating the url, you need to change the content in it? the constructor is executed only 1 time, that is, this.state.id is set once from the props, and then not anymore,
or so
https://ru.reactjs.org/docs/react-component.html#c...
---
ibid
https://ru.reactjs.org/docs/react-component.html#c...
Note:
Don't copy props into the state! This is a common mistake
...
https://overreacted.io/writing-resilient-components/
Read the article very carefully and find the cause of the problem.
// edit
The id parameter in state is written only in the constructor. For it to be updated, either getDerivedStateFromProps should be used, or setState should be called in componentDidUpdate if "props.params.match.number" has changed.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question