2 ms·
Is it just a syntactical difference or is there something more fundamental that I'm missing here?
by sktrdie 8y ago
Is it just a syntactical difference or is there something more fundamental that I'm missing here?
- acemarke 8y agoIt's a huge difference, and yet also the same thing. It's the same concepts of props, state, context, and lifecycle behavior as before. It's just that now you can do it in function components, not just class components, and the APIs let you handle things without having to have additional levels of wrapper components and without the complexity of class-related gotchas.
- tinalumfoil 8y agoCan someone give me an example where hooks replace a wrapper? All the examples I see can be replaced with a single class, albeit a couple more lines of code.
- acemarke 8y agoContext is a great example. Right now, each `<MyContext.Consumer>` instance shows up as another level of wrapping in the devtools, _and_ requires indentation/hierarchy in the render methods. With `const someValue = useContext(MyContext)`, there's no actual component being used, so both the component hierarchy and the render code itself is flatter.