jsx语法->createElement()->React元素 父组件更新,子组件跟着更新. # 组件优化 ### 减轻state,与渲染无关的不要放在state中. ### 避免不必要的重新渲染. 钩子函数 shouldComponentUpdate(nextProps,nextState) 根据返回值判断是否需要渲染该值. 触发时机:更新阶段的钩子函数,组件重新渲染前执行(shouldComponentUpdate->render) 或者使用纯组件 ```html class StateApp extends React.Component{ constructor(){ super() this.state= { count:0 } } shouldComponentUpdate(nextProps,nextState){ console.info('最新是内容'+nextState.count) console.info('上次是内容'+this.state.count) return nextState.count!==this.setState.count } onIncrement=()=>{ console.info('事件处理this'+this) this.setState((state,props)=> { return { count:state.count+1 } }) console.info(this.state.count) } render(){ return (