mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
Add test fixture showing invalid location
Add test fixture showing invalid location The error should be on the node mutating the output, not in the read location.
This commit is contained in:
+28
@@ -0,0 +1,28 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
function useInvalidMutation(options) {
|
||||
function test() {
|
||||
foo(options.foo); // error should not point on this line
|
||||
options.foo = "bar";
|
||||
}
|
||||
return test;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Error
|
||||
|
||||
```
|
||||
1 | function useInvalidMutation(options) {
|
||||
2 | function test() {
|
||||
> 3 | foo(options.foo); // error should not point on this line
|
||||
| ^^^^^^^^^^^ [ReactForget] InvalidReact: Mutating props or hook arguments is not allowed. Consider using a local variable instead. (3:3)
|
||||
4 | options.foo = "bar";
|
||||
5 | }
|
||||
6 | return test;
|
||||
```
|
||||
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
function useInvalidMutation(options) {
|
||||
function test() {
|
||||
foo(options.foo); // error should not point on this line
|
||||
options.foo = "bar";
|
||||
}
|
||||
return test;
|
||||
}
|
||||
Reference in New Issue
Block a user