React:useState
lastmod 2023-03-09created 2022-09-193 edits
What does setState do?
setState() schedules an update to a component's state object. When state changes, the component re-renders.
What is the difference between state and props?
props (short for properties) and state are both plain JavaScript objects.
While both hold information that influences the output of render, they are different in one important way.
-
propsget passed to the component (similar to function parameters), whereas -
stateis managed within the component (similar to variables declared within a function).