1.如何创建组件:
React.createClass({
getInitialState: function () {
return {} // 返回state
},
render: function () {return <div></div>}
})
2.组件中得属性:
this.state:getInitialState返回的
this.props:标签里面的属性
3.组件的生命周期:
装载组件触发:
- componentWillMount
只会在装载之前调用一次,在 render 之前调用
- componentDidMount
只会在装载完成之后调用一次,在 render 之后调用
更新组件触发:
componentWillRecevieProps
shouldComponentUpdate
componentWillUpdate
componentDidUpdate
卸载组件触发:
componentWillUnmount
4.使用webpack打包react
github地址
5.react-native
教程
https://devdactic.com/react-native-firebase-todo/
6.有用文章
已买到的宝贝前端组件化探索
http://taobaofed.org/blog/2015/11/02/buy-component/
React Native实战 by 鬼道@天猫
http://airjd.com/view/iap1mz440004r90#33
一个资深iOS开发者对于React Native的看法
http://www.linuxidc.com/Linux/2015-09/123239.htm
参考资料:
React 入门教程 https://hulufei.gitbooks.io/react-tutorial/content/introduction.html
深入浅出React http://www.infoq.com/cn/articles/react-art-of-simplity