Skip to content

Commit 9fc340a

Browse files
committed
docs: keepPreviouseData 예제 추가
1 parent 795bdc0 commit 9fc340a

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

README.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ const {
628628
- [Removed keepPreviousData in favor of placeholderData identity function](https://github.com/ssi02014/react-query-tutorial/blob/main/document/v5.md#9-%EF%B8%8F-removed-keeppreviousdata-in-favor-of-placeholderdata-identity-function)
629629

630630
- 이들은 각각 `placeholderData``isPlaceholderData` 플래그와 거의 유사하게 동작하기 때문이다.
631-
- 아래 예제처럼 `placeholderData`를 활용하면서 이전 버전에서 `keepPreviousData의 값을 true`로 줬을 때와 동일한 기능을 수행할 수 있다.
631+
- 아래 예제처럼 `placeholderData`를 활용하면서 이전 버전에서 `keepPreviousData의 값을 "true"`로 줬을 때와 동일한 기능을 수행할 수 있다.
632632

633633
```tsx
634634
import { useQuery, keepPreviousData } from "@tanstack/react-query";
@@ -643,6 +643,21 @@ const {
643643
});
644644
```
645645

646+
- 아래 예시처럼 작성해서 위 keepPreviousData 예시와 동일한 동작을 할 수 있다.
647+
648+
```tsx
649+
import { useQuery } from "@tanstack/react-query";
650+
651+
const {
652+
data,
653+
// ...
654+
} = useQuery({
655+
queryKey: ["super-heroes"],
656+
queryFn: getAllSuperHero,
657+
placeholderData: (previousData, previousQuery) => previousData,
658+
});
659+
```
660+
646661
<br />
647662

648663
## Parallel

0 commit comments

Comments
 (0)