You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// bad (relying on function name inference is discouraged)constListing=({ hello })=>(<div>{hello}</div>);// goodfunctionListing({ hello }){return<div>{hello}</div>;}
如果模块有内部状态或者是refs, 推荐使用 class extends React.Component
1.UI组件和container组件
UI组件是构成前端界面的基础单元,它们不涉及业务逻辑,无生命周期函数,只负责单纯的渲染,所有数据都通过 props 传入。
UI组件分为两种情况,有状态组件和无状态组件:
2. components导出默认模块
3.总是在Refs里使用回调函数
4.this.props.children
5.PropTypes
6.模块生命周期
class extends React.Component
的生命周期函数:static
方法constructor
构造函数getChildContext
获取子元素内容componentWillMount
模块渲染前componentDidMount
模块渲染后componentWillReceiveProps
模块将接受新的数据shouldComponentUpdate
判断模块需不需要重新渲染componentWillUpdate
上面的方法返回true
, 模块将重新渲染componentDidUpdate
模块渲染结束componentWillUnmount
模块将从DOM中清除, 做一些清理任务onClickSubmit()
或onChangeDescription()
render
里的 getter 方法 如getSelectReason()
或getFooterContent()
renderNavigation()
或renderProfilePicture()
render
render() 方法如何定义
propTypes
,defaultProps
,contextTypes
, 等等其他属性...参考
The text was updated successfully, but these errors were encountered: