React.memoの注意点
React.memoの第1引数にcomponentを指定することでrenderingを抑制できるが、闇雲に使うとパフォーマンスが下がる
デフォルトだとshallow compareによって比較されるため、無駄が多い
また、ネストの深いpropsの場合bugsを生む可能性がある
公式ドキュメントよりReact.PureComponent’s shouldComponentUpdate() only shallowly compares the objects. If these contain complex data structures, it may produce false-negatives for deeper differences. Only extend PureComponent when you expect to have simple props and state, or use forceUpdate() when you know deep data structures have changed. Or, consider using immutable objects to facilitate fast comparisons of nested data.
rules
第2引数にrenderingの条件を指定する
第2引数はshouldComponentUpdateと基本的には同じだが、trueを返す場合のみre-renderingを抑制する
参考