Skip to content

Function components - state and lifecycle #44

@vineetdigit

Description

@vineetdigit

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions