-
-
Notifications
You must be signed in to change notification settings - Fork 324
Implement Model Identity Keys #345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
a1b3a06
to
a17a57e
Compare
1ac1c7a
to
1e84aab
Compare
also add comment about why we inject extra validation in debug mode
all makes event handler targets deterministic based on keys and child indices
At the moment, whenever a particular branch of a layout is updated, all the state (i.e. hooks and event handlers) that live within that branch are thrown away and reconstructed. Given IDOM’s current implementation for Layout this is unavoidable. To resolve this issue, we need to add a concept of “keys” which can be used to indicate the identity of an element within the layout structure. For example, if you have a list of elements that get re-ordered when a button is pressed, their state should be preserved, and reassigned to their new location in the layout. By default React requires keys to be used to communicate element identity whenever the order or number of simbling elements can change. While there are clear performance benefits for adhering to this stipulation, it’s often confusing for new developers. React has the further advantage of the JSX syntax, which makes it easier for the program to determine exactly when keys must be supplied by the user. To make the experience for new users simpler, and due to a lack of inforcement via JSX, IDOM will be to assume that any element without a key is new. Thus, for IDOM, keys will primarilly be a tool for optimization rather than a functional requirement.
this needs to be cleaned up now that we know what the bugs were
also fixes mypy typing issues
we can change this in a later pull request
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.
closes: #330
See the React docs for more info on this type of feature: https://reactjs.org/docs/lists-and-keys.html
This will allow the layout to know whether or not the identity of any particular model has changed, and thus, whether or not its state should be replaced.