I just started using Facebook’s React library and want to share the most important things that one should always keep in mind when using library.
I will list below some things starting from the most important ones.
I suggest you watch the video below about it:
Few important things that you always should keep in mind are:
render()method is always called when state of component is changed
render()method does not completely re-render DOM node every time, instead it uses virtual DOM mechanism to detect changes and then apply only them
You should keep
render()as flat as it is possible and should never use
setState()there as it may cause infinite loops
You can access sub components using
You definitely may want to add JSX sugar to your react app, but remember that it is not part of react library itself
Quick start project
You might want to check quick start project that I published here.
Via git (or downloaded tarball):
$ git clone git://github.com/gevorg/react-quick-start.git
$ cd react-quick-start $ npm install $ npm start > node app.js Listening on 5000 ...