News for hackers. Stuff that matters.
Re:Why is setState asynchronous? by tmppdi9876 on Thursday January 25, 2018 @01:25PM (#16233166)
What i like to do is to write every component as a stateless component. This way you can write a wrapper component that handles local state, lifecycle methods etc and just pass the needed functions and variables to the dumb component or you can switch to redux. The component doesn't care it just needs to have the state altering functions as parameters and the updated state. The problem i see is when new developers start writing a huge class that is coupled with the state handling and calling this all over the place.
Re:Why is setState asynchronous? by crooked-v on Thursday January 25, 2018 @01:39PM (#16233289)
I use withState from recompose heavily for this reason.
Re:Why is setState asynchronous? by baddox on Thursday January 25, 2018 @02:40PM (#16233872)
That’s what I do. Even if you’ll likely never use the stateless component directly in an app, it makes automated testing and things like Storybook much simpler.