const renderItem = (item: string, index: number) => { console.log(warpProps.handleItemDelete) return ( <List.Item>
<p onClick={warpProps.handleItemDelete(index)}>{item}</p>
</List.Item>
)
}報(bào)錯(cuò)Warning: Cannot update during an existing state transition (such as within `render`). Render methods should be a pure function of props and state.如果是匿名函數(shù)const renderItem = (item: string, index: number) => { console.log(warpProps.handleItemDelete) return ( <List.Item>
<p onClick={() => warpProps.handleItemDelete(index)}>{item}</p>
</List.Item>
)
}報(bào)錯(cuò)Lambdas are forbidden in JSX attributes due to their rendering performance impact
react - ts中,render內(nèi)不允許匿名函數(shù),如果不使用匿名函數(shù),則提示不允許更新state
繁花如伊
2019-01-31 21:02:07