1. Mounting
- useState and useEffect are called during the mounting phase.
- useState sets the initial state of the component.
- useEffect is used to perform any side effects after the component has mounted.
2. Updating
- Whenever the component state or props change, the component re-renders.
- During the updating phase, useEffect is called again.
- Any changes to the state or props can be handled here.
3. Unmounting
- When the component is removed from the DOM, useEffect can be used for cleanup operations.
- The cleanup function is called right before the component is unmounted.
**Note: The lifecycle diagram above applies to functional components that use hooks. Without hooks, the lifecycle is simpler and does not have a separate phase for useEffect.**
-
Notifications
You must be signed in to change notification settings - Fork 3
ProgrammingHero1/react-functional-component-lifecycle
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description, website, or topics provided.
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published