ReactNote
ReactNote copied to clipboard
JSX 条件语句中错误的方式导致组件未重新挂载(涉及组件diff原理)
https://thoughtspile.github.io/2022/01/17/jsx-conditionals/
{condition ? <Tag props1 /> : <Tag props2 />} will not remount Tag — use unique key or separate && branches if you want the remount.
Diff 原理:https://juejin.cn/post/6844903973585944589 先比较组件type,再比较 key,之后比较位置 index