3 ms·
What’s the reason to avoid class components though? The official tutorial still uses it, though that could just be because it’s outdated?
by poyu 6y ago
What’s the reason to avoid class components though? The official tutorial still uses it, though that could just be because it’s outdated?
- ritchiea 6y agoThe zeitgeist is that hooks are easier to reason about than life cycle methods, functional components are more lightweight and result in less bundled code.
- hitekker 6y agoIt's more of a hype train than a "zeitgeist". Major community contributors like Jared Palmer have stepped forward in the past year to critique the complexity of React hooks. https://jaredpalmer.com/blog/react-is-becoming-a-black-box https://jaredpalmer.com/blog/react-is-becoming-a-black-box https://dillonshook.com/a-critique-of-react-hooks-addendum/ https://dillonshook.com/a-critique-of-react-hooks-addendum/ Personally, I think blindly adopting the latest frontend trends is the opposite of being "radically pragmatic".
- acemarke 6y agoThe React team is currently working on a complete rewrite of the docs, which will include a focus on hooks first: https://github.com/reactjs/reactjs.org/issues/3308 https://github.com/reactjs/reactjs.org/issues/3308 In the meantime, someone else ported the existing docs to teach function components and hooks in the examples: https://reactwithhooks.netlify.app/ https://reactwithhooks.netlify.app/