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
Lauren Tan committed
Feb 1, 2024 at 11:02 UTC
a0aa66ca8f68bdc66f04e8aa55a7f41a52c41f0d
2 files changed
+27
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-function-property.expect.md
new
+21
@@ -0,0 +1,21 @@
1
+
2
+## Input
3
+
4
+```javascript
5
+export function ViewModeSelector(props) {
6
+ const renderIcon = () => <AcceptIcon />;
7
+ renderIcon.displayName = "AcceptIcon";
8
+
9
+ return <Dropdown checkableIndicator={{ children: renderIcon }} />;
10
+}
11
+
12
+```
13
+
14
+
15
+## Error
16
+
17
+```
18
+[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)
19
+```
20
+
21
+
\ No newline at end of file
compiler/packages/babel-plugin-react-forget/src/__tests__/fixtures/compiler/error.mutate-function-property.js
new
+6
@@ -0,0 +1,6 @@
1
+export function ViewModeSelector(props) {
2
+ const renderIcon = () => <AcceptIcon />;
3
+ renderIcon.displayName = "AcceptIcon";
4
+
5
+ return <Dropdown checkableIndicator={{ children: renderIcon }} />;
6
+}