Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Function components - state and lifecycle #44

Open
vineetdigit opened this issue Sep 2, 2020 · 0 comments
Open

Function components - state and lifecycle #44

vineetdigit opened this issue Sep 2, 2020 · 0 comments

Comments

@vineetdigit
Copy link

vineetdigit commented Sep 2, 2020

There are references to "function components" on this page that need correction.

State hoisting
function-component don't hold state (as the name implies).

With the introduction of hooks, function components do hold state. useState() hook in particular allows function components to store state. See https://reactjs.org/docs/hooks-state.html

This pattern isn't limited to function components. Because function components don't have lifecycle events, you'll use this pattern with component classes as well.

This is inaccurate as well. Function components do have lifecycle the same way class components have. Again with the introduction of hooks, useEffect() hooks allows function component to implement all lifecycle methods that class components allows. See https://reactjs.org/docs/hooks-effect.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant