Repository navigation
Clarify immutability lint does not report method-call mutations on state - #8759
Open
officialasishkumar wants to merge 1 commit into
Open
officialasishkumar wants to merge 1 commit into
officialasishkumar wants to merge 1 commit into
Conversation
β¦on state The immutability rule page listed items.push(), items.sort() and the todos.push() troubleshooting example as violations the rule catches. The compiler does not infer the types of state values, so it only reports mutations it can prove (such as property assignment) and produces no diagnostic for these method calls. Keep the property assignment as the invalid example, add a note that method-call mutations on state are not detected yet, and show a non-mutating sort in the valid examples.
Size changesDetailsπ¦ Next.js Bundle Analysis for react-devThis analysis was generated by the Next.js Bundle Analysis action. π€ This PR introduced no changes to the JavaScript bundle! π |
This branch was successfully deployed
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.
Fixes #8758
The
immutabilitypage listeditems.push(4),setItems(items.sort())and thetodos.push()troubleshooting example as violations the rule reports. The compiler doesn't infer the types of state values, so it only errors on mutations it can prove, such asuser.name = 'Bob'; method calls on state produce no diagnostic (see react/react#35157).Changes:
push()/sort()on state aren't reported yet but are still bugs.sortto the valid examples.push()on state.