Hacker News new | past | comments | ask | show | jobs | submit login

Okay. But how do you know what components to call setState on then? Is state spread over components, or is it stored centrally?



setState is a public API, usually triggered in response to a user event like a click or an input change event.

State in React is local to a component, but it can be passed down to a component's children in the form of props.

Centralized state can be achieved using a library like Redux, where an individual component subscribes to an external data store's changes. Redux abstracts the details away, but under the hood it's still just setState.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: