Memorization
// 只要 props 沒變就不會 re-render
function TableValues(props) {}
export default React.memo(TableValues)適用 child component 是 pure 也就是沒有 useStae, useContext 時
Implement memo
array 是 by reference 所以 map 的 key 不能直接 [1, 2] ,不然有可能
// map
{
[1,2]: 3,
[1,2]: 3,
[1,2]: 3
}
// need to convert to like 1_2
{
"1_2": 3
}Last updated
Was this helpful?