React - One Direction Data Flow

React - One Direction Data Flow
0

#1

I’m reading Facebook’s intro to React (Highly recommended).
One key feature is explained in this screenshot.

I guess it is an issue of encapsulation - a child component can’t mess with the data/state of it’s parent component. Of course it can have it’s own state, and do data manipulations before rendering. But data belonging to the parent is kept safe. Is my understanding correct?
Thanks in advance!


#2

React wants to emphasize reusability. Your component should behave the same way if you feed it the same data. Regardless of what its parent or children are. That’s not just a react thing really, it’s the idea of functional programming.

React in general preaches immutability of data. It keeps your applications predictable and changes easier to track.

A child component shouldn’t directly change the state of its parent, but you can use child component to retrieve data required to update the state of a parent component. Most common example of this is some sort of text input that changes the view, like posting a message to a message board