-
Notifications
You must be signed in to change notification settings - Fork 24.3k
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
[2/2] Constrain data type in getItemLayout
callback
#36237
Closed
Closed
Conversation
This file contains 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
facebook-github-bot
added
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
p: Facebook
Partner: Facebook
Partner
fb-exported
labels
Feb 22, 2023
This pull request was exported from Phabricator. Differential Revision: D43466967 |
NickGerleman
changed the title
Constrain data type in
[2/2] Constrain data type in Feb 22, 2023
getItemLayout
callbackgetItemLayout
callback
This pull request was exported from Phabricator. Differential Revision: D43466967 |
NickGerleman
added a commit
to NickGerleman/react-native
that referenced
this pull request
Feb 22, 2023
Summary: Pull Request resolved: facebook#36237 This changes the data parameter type for `getItemCallback` from a mutable array (too lenient, even before), to a `$ArrayLike`, which is now the most constrained subset of data which may be passed to a FlatList. We could do something more exact by adding another generic parameter to FlatList, but that would be likely be noticeably more breaking, since during testing I couldn't manage a pattern that both kept the same minimum number of generic arguments while keeping inference working. Changelog: [General][Breaking] - Constrain data type in `getItemLayout` callback Differential Revision: D43466967 fbshipit-source-id: 853feeecc4ab2934f4f527a1db4464c09163102f
NickGerleman
force-pushed
the
export-D43466967
branch
from
February 22, 2023 00:22
7dcfa6d
to
de56dab
Compare
Base commit: a2f155f |
Summary: Pull Request resolved: facebook#36236 D38198351 (facebook@d574ea3) addedd a guard to FlatList, to no-op if passed `data` that was not an array. This broke functionality where Realm had documented using `Realm.Results` with FlatList. `Real.Results` is an array-like JSI object, but not actually an array, and fails any `Array.isArray()` checks. This change loosens the FlatList contract, to explicitly allow array-like non-array entities. The requirement align to Flow `$ArrayLike`, which allows both arrays, and objects which provide a length, indexer, and iterator. Though `Realm.Results` has all the methods of TS `ReadonlyArray`, RN has generally assumes its array inputs will pass `Array.isArray()`. This includes any array props still being checked [via prop-types](https://github.com/facebook/prop-types/blob/044efd7a108556c7660f6b62092756666e39d74b/factoryWithTypeCheckers.js#L548). This change intentionally does not yet change the parameter type of `getItemLayout()`, which is already too loose (allowing mutable arrays). Changing this is a breaking change, that would be disruptive to backport, so we separate it into a different commit that will be landed as part of 0.72 (see next diff in the stack). Changelog: [General][Changed] - Make FlatList permissive of ArrayLike data Differential Revision: https://www.internalfb.com/diff/D43465654?entry_point=27 fbshipit-source-id: 15c9e19414b82ea8676df0428c5540097107259c
Summary: Pull Request resolved: facebook#36237 This changes the data parameter type for `getItemLayout` from a mutable array (too lenient, even before), to `ArrayLike`, which is now the most constrained subset of data which may be passed to a FlatList. We could do something more exact by adding another generic parameter to FlatList, but that would be likely be noticeably more breaking, since during testing I couldn't manage a pattern that both kept the same minimum number of generic arguments while keeping inference working. Changelog: [General][Breaking] - Constrain data type in `getItemLayout` callback Reviewed By: javache Differential Revision: D43466967 fbshipit-source-id: a0fa45917dfe9dcb71c543b6c86d0ce188a48c4c
NickGerleman
force-pushed
the
export-D43466967
branch
from
February 22, 2023 22:41
de56dab
to
c7c0f05
Compare
This pull request was exported from Phabricator. Differential Revision: D43466967 |
This pull request has been merged in febf6b7. |
OlimpiaZurek
pushed a commit
to OlimpiaZurek/react-native
that referenced
this pull request
May 22, 2023
Summary: Pull Request resolved: facebook#36237 This changes the data parameter type for `getItemLayout` from a mutable array (too lenient, even before), to `ArrayLike`, which is now the most constrained subset of data which may be passed to a FlatList. We could do something more exact by adding another generic parameter to FlatList, but that would be likely be noticeably more breaking, since during testing I couldn't manage a pattern that both kept the same minimum number of generic arguments while keeping inference working. Changelog: [General][Breaking] - Constrain data type in `getItemLayout` callback Reviewed By: javache Differential Revision: D43466967 fbshipit-source-id: 7a1ce717e7d5cc96a58b8d3ad9def6cf6250871f
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
CLA Signed
This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed.
fb-exported
Merged
This PR has been merged.
p: Facebook
Partner: Facebook
Partner
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.
Summary:
This changes the data parameter type for
getItemLayout
from a mutable array (too lenient, even before), to a$ArrayLike
, which is now the most constrained subset of data which may be passed to a FlatList.We could do something more exact by adding another generic parameter to FlatList, but that would be likely be noticeably more breaking, since during testing I couldn't manage a pattern that both kept the same minimum number of generic arguments while keeping inference working.
Changelog:
[General][Breaking] - Constrain data type in
getItemLayout
callbackDifferential Revision: D43466967