When will the react Component remount?

I hear React itself use Object.is to decide whether to reRender a component or not How about remounted? What does React check? I give Object.is a try in the link, but it ends up "not this" https://stackblitz.com/edit/react-ts-tuqhjk?file=App.tsx,index.html
understand unmounted - StackBlitz
React + TypeScript starter project
2 Replies
JacobMGEvans
JacobMGEvans17mo ago
Interesting. I'm pretty sure there isn't a comparison check done, once the component unmounts basically being removed from VDOM and subsequently the DOM, likely the only thing it does on a "remount" is the same thing it does during a mounting phase
gray0531
gray053117mo ago
I think that a hidden , unique id is created and append on the component itself when calling createElement(MyComponent) , it will help the react to identify whether to mount it or just rerender it. If a functional component is defined in another component, {the new id is created because the function is not the same} , so new vDom is created , during reconciliation, an unmount and a mount happen. But, I find no doc to prove poohhehpoohheh Below is not for sure. Another situation related is render props, it seems like a line function definition(!! I try this, it will not remount) We do not use it like this : <RenderProps someValue> We use it like this: RendrProps(someValue) In this case, because the RendrProps(someValue) return something , and this something will be put inside createElement. Not the RenderProps it self. so no id related problem no remount.