Skip to main content

What does useState() return?

Entry React
Quick Answer useState returns an array with two things: the current state value and a setter function. const [count, setCount] = useState(0) รขโ‚ฌโ€ count holds the current value, setCount triggers a re-render with the new value. The initial value (0 here) is only used on the first render.

Answer

useState returns an array with the current state value and a function to update that state.
S
SugharaIQ Editorial Team Verified Answer

This answer has been peer-reviewed by industry experts holding senior engineering roles to ensure technical accuracy and relevance for modern interview standards.

Want to bookmark, take notes, or join discussions?

Sign in to access all features and personalize your learning experience.

Sign In Create Account

Source: SugharaIQ

Ready to level up? Start Practice