react.backbone icon indicating copy to clipboard operation
react.backbone copied to clipboard

About props and State when using react.backbone

Open walnutpedia opened this issue 10 years ago • 4 comments

I read some articles on React Props and State and get confused about that. props should not be modified if I didn't misunderstand props and state... when using react.backbone, the model was passing in a component via props, and the model definitely will change, right? is that proper to update the component this way? sorry if this question is too silly...

walnutpedia avatar May 20 '15 09:05 walnutpedia

The props don't change, but their contents can change. So you pass a user. The user doesn't change, but his avatar_url might. In general the philosophy of backbone is a bit different from the philosophy of react, so in 'pure' react you indeed wouldn't do this, but pass in only a dumb object (like model.attributes)

markijbema avatar May 20 '15 11:05 markijbema

@markijbema thanks for your comment. one interesting thing that i've found is that another plugin called backbone-react-component seems use the state to hold the model data. so maybe that's just two different ways. anyhow, they both work.

walnutpedia avatar May 21 '15 07:05 walnutpedia

+1 this confused me too. Thanks for clarifying - maybe add this quick explanation to README?

Thanks!

alvesl avatar Jul 11 '16 22:07 alvesl

Good idea; could you make a pull-request on the readme?

markijbema avatar Jul 12 '16 07:07 markijbema