mirror of
https://github.com/facebook/react.git
synced 2025-11-01 09:12:30 +00:00
[test] Add tests for mutating a global
The error is thrown correctly but the error message is incorrect.
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
let wat = {};
|
||||
|
||||
function Foo() {
|
||||
delete wat.foo;
|
||||
return wat;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Error
|
||||
|
||||
```
|
||||
[ReactForget] InvalidReact: This mutates a variable after it was passed to React, which means that React cannot observe changes to it (4:4)
|
||||
```
|
||||
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
let wat = {};
|
||||
|
||||
function Foo() {
|
||||
delete wat.foo;
|
||||
return wat;
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
|
||||
## Input
|
||||
|
||||
```javascript
|
||||
let wat = {};
|
||||
|
||||
function Foo() {
|
||||
wat.test = 1;
|
||||
return wat;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
## Error
|
||||
|
||||
```
|
||||
[ReactForget] InvalidReact: This mutates a variable after it was passed to React, which means that React cannot observe changes to it (4:4)
|
||||
```
|
||||
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
let wat = {};
|
||||
|
||||
function Foo() {
|
||||
wat.test = 1;
|
||||
return wat;
|
||||
}
|
||||
Reference in New Issue
Block a user