File tree Expand file tree Collapse file tree 4 files changed +43
-14
lines changed
examples/optimistic-updates-typescript Expand file tree Collapse file tree 4 files changed +43
-14
lines changed Original file line number Diff line number Diff line change 246246 "path" : " /examples/optimistic-updates" ,
247247 "editUrl" : " /examples/optimistic-updates.mdx"
248248 },
249+ {
250+ "title" : " Optimistic Updates in TypeScript" ,
251+ "path" : " /examples/optimistic-updates-typescript" ,
252+ "editUrl" : " /examples/optimistic-updates-typescript.mdx"
253+ },
249254 {
250255 "title" : " Pagination" ,
251256 "path" : " /examples/pagination" ,
Original file line number Diff line number Diff line change 1+ ---
2+ id : optimistic-updates-typescript
3+ title : Optimistic Updates in TypeScript
4+ toc : false
5+ ---
6+
7+ - [ Open in CodeSandbox] ( https://codesandbox.io/s/github/tannerlinsley/react-query/tree/master/examples/optimistic-updates-typescript )
8+ - [ View Source] ( https://github.com/tannerlinsley/react-query/tree/master/examples/optimistic-updates-typescript )
9+
10+ <iframe
11+ src = " https://codesandbox.io/embed/github/tannerlinsley/react-query/tree/master/examples/optimistic-updates-typescript?autoresize=1&fontsize=14&module=%2Fpages%2Findex.tsx&theme=dark"
12+ title = " tannerlinsley/react-query: optimistic-updates-typescript"
13+ sandbox = " allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
14+ style = { {
15+ width: ' 100%' ,
16+ height: ' 80vh' ,
17+ border: ' 0' ,
18+ borderRadius: 8 ,
19+ overflow: ' hidden' ,
20+ position: ' static' ,
21+ zIndex: 0 ,
22+ }}
23+ ></iframe >
Original file line number Diff line number Diff line change 44 "main" : " index.js" ,
55 "license" : " MIT" ,
66 "dependencies" : {
7+ "@types/react" : " ^17.0.0" ,
8+ "@types/node" : " 14.14.14" ,
79 "axios" : " ^0.19.2" ,
810 "isomorphic-unfetch" : " 3.0.0" ,
911 "next" : " 9.2.2" ,
1012 "react" : " ^17.0.1" ,
1113 "react-dom" : " ^17.0.1" ,
12- "react-query" : " ^3.2.0-beta.32" ,
13- "react-query-devtools" : " ^3.0.0-beta.1" ,
14+ "react-query" : " 3.5.1" ,
1415 "typescript" : " ^4.1.2"
1516 },
1617 "scripts" : {
Original file line number Diff line number Diff line change @@ -9,20 +9,10 @@ import {
99 QueryClientProvider ,
1010 UseQueryOptions ,
1111} from 'react-query'
12- import { ReactQueryDevtools } from 'react-query- devtools'
12+ import { ReactQueryDevtools } from 'react-query/ devtools'
1313
1414const client = new QueryClient ( )
1515
16- export default function App ( ) {
17- return (
18- < QueryClientProvider client = { client } >
19- < Example />
20- < TodoCounter />
21- < ReactQueryDevtools initialIsOpen />
22- </ QueryClientProvider >
23- )
24- }
25-
2616type Todos = {
2717 items : readonly {
2818 id : string
@@ -37,7 +27,7 @@ async function fetchTodos(): Promise<Todos> {
3727}
3828
3929function useTodos < TData = Todos > (
40- options ?: UseQueryOptions < TData , AxiosError , Todos >
30+ options ?: UseQueryOptions < Todos , AxiosError , TData >
4131) {
4232 return useQuery ( 'todos' , fetchTodos , options )
4333}
@@ -143,3 +133,13 @@ function Example() {
143133 </ div >
144134 )
145135}
136+
137+ export default function App ( ) {
138+ return (
139+ < QueryClientProvider client = { client } >
140+ < Example />
141+ < TodoCounter />
142+ < ReactQueryDevtools initialIsOpen />
143+ </ QueryClientProvider >
144+ )
145+ }
You can’t perform that action at this time.
0 commit comments