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

I am confused: why is data made available as props and not as state?



This https://github.com/uberVU/react-guide/blob/master/props-vs-s... is a good explanation of the difference. But in short, it essentially comes down to who can manipulate the data. If the component will manipulate it, then it is state. On the other hand, if a difference source is going to be manipulating it, then it should be a prop. In this case, the client side of relay will be changing the data according to instruction from the server (e.g. a new message arrived). Therefore, the state is being passed as a prop.




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

Search: