You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This optimization is a renderer specific optimization. It is about knowing how React will process a particular component in its internals and then inlining that internal work into the user code.
functionFoo_optimizedMount(props){if(props.data.type==='img'){varimg=document.createElement('img');img.className=props.className;img.src=props.data.src;return{node: img,listeners: ReactEventListeners.trap(img,'error','load')};}varspan=document.createElement('span');span.className=props.className;varchildren=ReactChildren.mountNestedChildrenIntoParent(this.props.children,span);return{node: span, children };}functionFoo_optimizedUpdate(instance,oldProps,newProps){if(oldProps.data.type!==newProps.data.type){Foo_optimizedUnmount(instance);returnFoo_optimizedMount(newProps);}if(props.data.type==='img'){img.className=props.className;img.src=props.data.src;returninstance;}span.className=props.className;ReactChildren.updateNestedChildrenInParent(this.props.children,instance);returninstance;}functionFoo_optimizedUnmount(instance){if(oldProps.data.type!==newProps.data.type){Foo_optimizedUnmount(instance);returnFoo_optimizedMount(newProps);}if(props.data.type==='img'){ReactEventListeners.release(instance.listeners);}ReactChildren.unmountNestedChildrenInParent(instance);}
Composite Components
Similarly, composite components can pick different code branches to imperatively update its children. For example, a known constant value wouldn't be considered, and comparison of a single property can potentially bail out a tree.
Although it is unclear if this has significant benefits over these two other optimizations:
This optimization is a renderer specific optimization. It is about knowing how React will process a particular component in its internals and then inlining that internal work into the user code.
It comes in two flavors.
Known Host Component
Into this:
Composite Components
Similarly, composite components can pick different code branches to imperatively update its children. For example, a known constant value wouldn't be considered, and comparison of a single property can potentially bail out a tree.
Although it is unclear if this has significant benefits over these two other optimizations:
#3227
#7323
The text was updated successfully, but these errors were encountered: