Skip to content

Commit 086dafe

Browse files
committed
prettier
1 parent 723daa9 commit 086dafe

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

compiler/packages/babel-plugin-react-compiler/src/Inference/InferReferenceEffects.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2117,9 +2117,9 @@ function getWriteErrorReason(abstractValue: AbstractValue): string {
21172117
return "Mutating component props or hook arguments is not allowed. Consider using a local variable instead";
21182118
} else if (abstractValue.reason.has(ValueReason.State)) {
21192119
return "Mutating a value returned from 'useState()', which should not be mutated. Use the setter function to update instead";
2120-
} else if(abstractValue.reason.has(ValueReason.ReducerState)){
2120+
} else if (abstractValue.reason.has(ValueReason.ReducerState)) {
21212121
return "Mutating a value returned from 'useReducer()', which should not be mutated. Use the dispatch function to update instead";
2122-
} {
2122+
} else {
21232123
return "This mutates a variable that React considers immutable";
21242124
}
21252125
}

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/error.modify-useReducer-state.expect.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import { useReducer } from "react";
66

77
function Foo() {
8-
let [state, setState] = useReducer({foo:1});
8+
let [state, setState] = useReducer({ foo: 1 });
99
state.foo = 1;
1010
return state;
1111
}
@@ -17,7 +17,7 @@ function Foo() {
1717

1818
```
1919
3 | function Foo() {
20-
4 | let [state, setState] = useReducer({foo:1});
20+
4 | let [state, setState] = useReducer({ foo: 1 });
2121
> 5 | state.foo = 1;
2222
| ^^^^^ InvalidReact: Mutating a value returned from 'useReducer()', which should not be mutated. Use the dispatch function to update instead (5:5)
2323
6 | return state;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useReducer } from "react";
22

33
function Foo() {
4-
let [state, setState] = useReducer({foo:1});
4+
let [state, setState] = useReducer({ foo: 1 });
55
state.foo = 1;
66
return state;
77
}

compiler/packages/babel-plugin-react-compiler/src/__tests__/fixtures/compiler/useReducer-returned-dispatcher-is-non-reactive.expect.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function f() {
99

1010
const onClick = () => {
1111
dispatch();
12-
}
12+
};
1313

1414
return <div onClick={onClick} />;
1515
}
@@ -52,6 +52,6 @@ export const FIXTURE_ENTRYPOINT = {
5252
};
5353

5454
```
55-
55+
5656
### Eval output
57-
(kind: ok) <div></div>
57+
(kind: ok) <div></div>

0 commit comments

Comments
 (0)