My Application is using React 15
and we are avoiding usages of componentWillReceiveProps
in components(so that it is less work at time of migrating to React 16+). Keeping this in mind, the appropriate place to set State based on previous props is componentDidUpdate
. But with linter rule react/no-did-update-set-state
we are getting below error:
error Do not use setState in componentDidUpdate react/no-did-update-set-state
From the explanation given https://github.com/yannickcr/eslint-plugin-react/blob/master/docs/rules/no-did-update-set-state.md, rule makes sense.
What is alternative(without disabling rule)... means where should we set state to abide by this rule?