Can I use useEffect to store state?
No. useEffect is for side effects, not for storing state. State belongs in useState. You can update state from inside an effect, but the storage itself is always useState.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in useEffect vs useState: Different Roles in a React Component
useState holds data inside a component and triggers a re-render when it changes. useEffect runs side effects after render in response to state or prop changes. useState stores; useEffect reacts.
No. Fetching is a side effect and belongs in useEffect. useState only holds the data once it is fetched. The common pattern is to fetch in useEffect and store the result in useState.
State changes trigger re-renders, and effects can read the new state and act on it. A typical pattern is useState holding fetched data while useEffect fetches it on mount and updates the state.
Still have questions?
Browse all our FAQs or reach out to our support team
