Adaptive site: refactor Island defer props#8967
Merged
Conversation
80a6c46 to
3231a33
Compare
312ac01 to
30ce3c2
Compare
|
Size Change: 0 B 🆕 Total Size: 0 B |
30ce3c2 to
abef462
Compare
abef462 to
1e2b436
Compare
prevent impossible states from being representable Co-authored-by: Alex Sanders <[email protected]>
1e2b436 to
1d8e3ee
Compare
defer propsdefer props
abeddow91
approved these changes
Oct 5, 2023
cemms1
reviewed
Oct 5, 2023
Comment on lines
+37
to
+39
| // this is just to stop Jest complaining about no tests | ||
| test('this is not a real test, ignore it, it tells you nothing useful 💃', () => | ||
| undefined); |
Contributor
There was a problem hiding this comment.
a future improvement could be to devise a neat way to check types like this in the future, hopefully without the need for this test
Member
There was a problem hiding this comment.
i promise to look at this properly 🤠
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.
What does this change?
Refactor the
deferisland prop.Before
After
See
Island.tsxspecificallyWhy?
This simplifies the types for Islands that are not deferred until visible. For example:
type IdleProps = { - deferUntil: 'idle'; + until: 'idle'; - rootMargin?: never; }; type VisibleProps = { - deferUntil: 'visible'; + until: 'visible'; rootMargin?: string; };This simplification will greatly reduce the complexity of introducting a new
priorityprop (#8970), which, likeVisibleProps, only allows specific combinations of props. This adheres to the principle of making impossible states unrepresentable. For example, valid combinations will be:This change enables a future where rather than props looking something like this:
They can now be written something like this:
Which means we no longer have to switch off invalid combinations with
key?: never, we simply do not create them (they can be discriminated away). This greatly improves the ratio of signal (key: 'value') v noise (key?: never).Follow-up on #8948 & #8944
Screenshots
N/A