-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Marks Select arrays as readonly #6999
base: develop
Are you sure you want to change the base?
Conversation
Generate changelog in
|
Invalidated by push of 933c1e2
compilefixBuild artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job. |
compileBuild artifact links for this commit: documentation | landing | table | demoThis is an automated comment from the deploy-preview CircleCI job. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like that this change forces consumers to deal with readonly arrays. Most code I have seen does not bother declaring arrays readonly, so returning readonly arrays in callbacks would break many such usages.
We're experimenting with a version that uses generics to return the same kind of array you pass in (readonly or not), and if that works out we will go with that approach instead. Otherwise, we'll come back to this.
@cybae0804 @invliD Here's an implementation that leverages generics as described: #6999 This accomplishes the same goal, while also having the advantage of being backwards compatible. This will hopefully make it much easier to transition existing code to use readonly arrays. |
Fixes #4976
Checklist
Changes proposed in this pull request:
Previous attempt + reversion #5171
Select components don't actually mutate the arrays provided, but because it is not marked as readonly, the consumers sometimes have to cast the prop to not be readonly. This fixes the issue by marking the props correctly as readonly.
Reviewers should focus on:
Screenshot