1.箭头函数(内联函数)
function addItem(){
log(111)
}
<Input onClick={()=>addItem}/>
此时input组件的点击事件,为内联函数创建一个新的实例,所以每次function都会指向不同的内存地址
2.[]
{this.props.items.map(i =>
<Cell data={i} options={this.props.options || []} />
)}
options为空,则会使用[]。[]每次会生成新的Array,因此导致Cell每次的props都不一样,导致需要重绘
- 传入参数若是引用类型的,若不想组件渲染,则尽量不要直接写字面量的方式
<BigListView items={items} style={{width: '100%'}}/> // style对象
BigListView 传入style 属性是个临时的对象字面量,每次 MyApp 重新渲染都会创建一个全新的 对象字面量。因此对 BigListView 而言每次传入的 props 都不同。