Fix React nodes being removed from DOM when they are still needed#7
Merged
Conversation
added 11 commits
August 19, 2018 23:11
… wrapper is unmounted
xjerwa
approved these changes
Aug 23, 2018
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pivotcomponent - wherePivotItemmay not be in the DOM but still needed for later.ng-templates passed asReactContentto be re-created every time (visible symptoms were multiple elements of the same type in the VDOM on initial component load, even though only one had a parent element actually contained in the DOM (element.isConnected === true).Please let me know your thoughts on the fix, the idea behind it is that the root cause for needing to unmount Angular DOM elements was due to multiple renders, each creating a new instance of a given React component, unmounting the old one.
The amount of calls for the render prop can't be controlled (The React component that was hosted the Angular one, in our case
office-ui-fabric-react'sCommandBardecides how many times to call the render prop - and since React render props are essentially SFC (stateless functional component), it returns the same JSX for the same props, every time, so calling it more than necessary, although discouraged*, would yield no side-effects).In the original (current) render prop wrapper implementation, a new
TemplateRefwas created for every render prop call.This PR changes the way render prop wrappers work to never re-create the template, but only re-assign the context on subsequent render calls.