News for hackers. Stuff that matters.
Re:React Fiber Architecture by amelius on Sunday August 07, 2016 @04:49PM (#12243580)
So how does React know which parts of the model need reconciling, without traversing the complete model and/or the complete state on every update?
Re:React Fiber Architecture by acdlite on Sunday August 07, 2016 @05:20PM (#12243708)
When you call setState on a component, only that component's subtree is reconciled and re-rendered.
Re:React Fiber Architecture by rukuu001 on Sunday August 07, 2016 @06:11PM (#12243981)
That's in the virtual DOM. React will diff the VDOM and browser DOM and only render actual differences.

The React API will also let a component decide for itself if it should be rendered.

Re:React Fiber Architecture by amelius on Sunday August 07, 2016 @06:58PM (#12244209)
Okay. But how do you know what components to call setState on then? Is state spread over components, or is it stored centrally?
Re:React Fiber Architecture by acdlite on Sunday August 07, 2016 @07:31PM (#12244371)
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.