Skip to content

Commit 3fd0186

Browse files
authored
Refactor useReducer type annotations in guide
Update useReducer type annotations and recommend typing for inline reducer functions.
1 parent db7ecd3 commit 3fd0186

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

src/content/blog/2024/04/25/react-19-upgrade-guide.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -715,14 +715,13 @@ type Example = ReactElement["props"];
715715
- useReducer<React.Reducer<State, Action>>(reducer)
716716
+ useReducer<State, [Action]>(reducer)
717717
```
718-
719718
reducer를 인라인으로 정의한다면 함수 매개변수에 타입을 지정하는 방식을 권장합니다.
720719
```diff
721720
- useReducer<React.Reducer<State, Action>>((state, action) => state)
722721
+ useReducer((state: State, action: Action) => state)
723722
```
724-
725723
이는 `useReducer` 호출문 밖으로 reducer를 분리할 때도 동일하게 적용됩니다.
724+
726725
```ts
727726
const reducer = (state: State, action: Action) => state;
728727
```

0 commit comments

Comments
 (0)