ubervu / react-guide Goto Github PK
View Code? Open in Web Editor NEWReact adventures
React adventures
I have another question about the table:
- | props | state |
---|---|---|
Can get initial value from parent Component? | Yes | Yes |
Can be changed by parent Component? | Yes | No |
... | ... | ... |
While I can understand that with getInitialState (and constructors in es6) I can set the initial state based just on the parent's value, it's still one more step to do**. Even more, here it's stated that in the majority of simple cases having props in getInitialState is an anti-pattern.
I cannot get the main idea of this yes and to my mind it's pretty confusing, so I'm asking for help. What am I missing here?
**What I mean by "one more step" is:
<Button color={'red'}>
...
// and in the button component
this.props.color
But how can I do the same with state?
This props vs. state table isn't getting rendered on GitHub:
https://github.com/uberVU/react-guide/blob/master/props-vs-state.md#changing-props-and-state
As far as I know changing props doesn't cause a component to re render. Props change will trigger componentWillReceiveProps and will only cause a re render if we update the state in this life cycle method?
I also posted this on the React issue list here
According to this guide, all items in the state of a react component have to be serializable. I would like to store a non-plain javascript object, what would be the consequences?
Thanks a lot for the super useful article. Sadly one of the links on the bottom of the page became private: https://groups.google.com/forum/#!forum/reactjs
cheers!
I have one question on this table:
- | props | state |
---|---|---|
Can get initial value from parent Component? | Yes | Yes |
Can be changed by parent Component? | Yes | No |
Can set default values inside Component?* | Yes | Yes |
Can change inside Component? | No | Yes |
Can set initial value for child Components? | Yes | Yes |
Can change in child Components? | Yes | No |
We can use 'setProps' in component. So I think props are able to change inside Component?
Thanks for any feedback!
Are they? are they only that?
Are they calculated during the graphical rendering by the browser?
Question from someone new to react, digging in atom sources, and seing @props all over the place and googling his way to your guide.
Nor sure how to submit a question so filed it as an issue. Sorry about that.
Thx for that document.
I found this table discussing the differences between props and state to be extremely helpful! Thanks for putting this guide together.
I've submitted a copy of the table to the official react docs, but I wanted to clarify the licensing. Is there a specific license under which your guide is available?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.