Writing cleaner state in React and React Native
Writing cleaner state in React and React Native
Ever since hooks got introduced in React, it made it a lot more easier to handle composition in react components and also helped the developers of react handle the component context a lot better. Also, as consumers of the library, we could finally avoid having to write this.methodName = this.methodName.bind(this)
which was a redundant part of the code to which a few developers ended up writing their own wrappers around the component context.
But that's old news, why bring it up now?
Well, as developers there's always some of us who just go ahead follow the standard as is even when it makes maintenance hard and in case of hooks, people seem to just ignore the actual reason for their existence all together.
If you witnessed the talk that was given during the release of hooks, this post might be not bring anything new to your knowledge. If you haven't seen the talk
You should.
I'm serious, go watch it!
For the rebels, who are still here reading this, here's a gist of how hooks are to be used.
https://reaper.im/posts/writing-cleaner-state-in-react.htmlThe post is a little on the longer side and contains code snippets, you can read the remaining on the blog