ArrowKeyStepper: setState(...) in `componentWillUpdate`
See original GitHub issueHi,
not sure if this should be considered an issue, but I thought it would not hurt to talk about it.
In the ArrowKeyStepper
component, into the componentWillUpdate
React lifecycle method, there is a call to setState(…).
I am not entirely sure that’s correct. (https://facebook.github.io/react/docs/react-component.html#componentwillupdate).
Isn’t it a best practice to use componentWillReceiveProps
instead?
Also, I see that the state is updated if the new set of props differ from the old set of props.
But this way, if the component updates its state as a result of key down events and then it receives a new pair of values for scrollToRow
and scrollToIndex
from a parent component (say, for example, as the result of clicking on one of the items of the wrapped List or Grid), those values will not end up in the state, and the component will not be able to reflect those in its render method.
(if not clear, I’ll try to come up with a small demo).
Thoughts?
Issue Analytics
- State:
- Created 7 years ago
- Comments:9 (5 by maintainers)
Top GitHub Comments
With a ref 😄
We could potentially do that as well.
Resolved by #592