Why does React.Children.map redraw in react

The

code is as follows: why does the whole component (including subcomponents) re-mount when currentItem.isLeaf changes

return React.Children.map([0,1,2,3,4,5,6], (Child, index) => {
      const ChildNode = currentItem.isLeaf === "1" ?
        AComponent :
        BComponent;

      return React.createElement(ChildNode,
        {
          amount: 5,
          index,
          key: `level-${index}`,
        }
      )
    })
Mar.24,2021

the answer is type is different .

The function signature of

React.createElement is React.createElement (type, props, children) .

React when doing dom diff , the first thing to judge is that type, will render again if the type is inconsistent (remove and then append).

when the subject currentItem.isLeaf changes, the corresponding type changes, so it will be re-rendered.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4baf4-43b0f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4baf4-43b0f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?