I am wondering about How react will render the component when on of the child component are same across different parent ?
Lets says
render(){
someFlag ? <div><MyComponent {...someprops} /></div> : <span><MyComponent {...someprops} /></span>
}
What i think is react many take a reference of MyComponent and serve the same reference with different props as it would be more efficient rather that creating new instance of the component, please guide me how react will render those changes should it create new instance as the parent component is different or my thinking is correct ?, still i am relatively new to react
This will lead to a performance issue. As the parent element has changed from div
to span
on condition change or vice-versa, React will reconstruct the underlying component i.e MyComponent
.
You can read more here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With