Hacker News new | past | comments | ask | show | jobs | submit login

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.



I use withState from recompose heavily for this reason.


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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: