Add test for function property mutation

There were no previous test paths that tested it, so I'm adding the example from 
https://github.com/facebookexternal/forget-feedback/issues/32 as a fixture
This commit is contained in:
Lauren Tan
2024-02-01 11:02:30 -05:00
parent d55420c430
commit a0aa66ca8f
2 changed files with 27 additions and 0 deletions
@@ -0,0 +1,21 @@
## Input
```javascript
export function ViewModeSelector(props) {
const renderIcon = () => <AcceptIcon />;
renderIcon.displayName = "AcceptIcon";
return <Dropdown checkableIndicator={{ children: renderIcon }} />;
}
```
## Error
```
[ReactForget] InvalidReact: This mutates a global or a variable after it was passed to React, which means that React cannot observe changes to it. (3:3)
```
@@ -0,0 +1,6 @@
export function ViewModeSelector(props) {
const renderIcon = () => <AcceptIcon />;
renderIcon.displayName = "AcceptIcon";
return <Dropdown checkableIndicator={{ children: renderIcon }} />;
}