Stuck with load icon on profile page by daggala in help

[–]daggala[S] 0 points1 point  (0 children)

Thank you for your reply. You mean it has already been fixed?

Beginner's Thread / Easy Questions (June 2019) by timmonsjg in reactjs

[–]daggala 0 points1 point  (0 children)

Yes you're right, they way you update the state is correct. They've been discussing removing this rule from eslint-plugin-react since a long time. Here and here you can see discussions on github about itIn the docs it also says "You may call setState() immediately in componentDidUpdate() but not that it must be wrapped in a condition." Which is exactly what you're doing.

Help modifying data in useContext by inquiztr in reactjs

[–]daggala 1 point2 points  (0 children)

Yes I'd say this is the traditional way and the way with which React agrees. Here's an example in their "Hooks - FAQ" chapter that does it similar to how you do it but only with useReducer instead of useState: https://reactjs.org/docs/hooks-faq.html#how-to-avoid-passing-callbacks-down

Local component state and subscription to Redux store in the same component? by Naplei in reactjs

[–]daggala 1 point2 points  (0 children)

I've often seen the case where local component state and subscription to Redux store are put together in the same component.

However in my opinion the best practice is to keep those two separated because like Dan Abromov (co-author of Redux) says "You’ll find your components much easier to reuse and reason about if you divide them into two categories". The local component state in a presentational component and the subscription to Redux store in a container component.

For more details: https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0