@@ -17,11 +17,18 @@ Please note that when playing with the examples in CodeSandbox that you can expe
17
17
18
18
## React Hooks
19
19
20
- <iframe src = " https://codesandbox.io/embed/rtk-query-demo-lbp7n?fontsize=12&hidenavigation=1&theme=dark&runonclick=1"
21
- style = { { width: ' 100%' , height: ' 800px' , border: 0 , borderRadius: ' 4px' , overflow: ' hidden' }}
22
- title = " rtk-query-react-hooks-example"
23
- allow = " geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
24
- sandbox = " allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
20
+ <iframe
21
+ src = " https://codesandbox.io/embed/rtk-query-demo-lbp7n?fontsize=12&hidenavigation=1&theme=dark&runonclick=1"
22
+ style = { {
23
+ width: ' 100%' ,
24
+ height: ' 800px' ,
25
+ border: 0 ,
26
+ borderRadius: ' 4px' ,
27
+ overflow: ' hidden' ,
28
+ }}
29
+ title = " RTK Query React Hooks Example"
30
+ allow = " geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
31
+ sandbox = " allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
25
32
></iframe >
26
33
27
34
## React Optimistic Updates
@@ -32,20 +39,34 @@ In the example below you'll notice a few things. There are two `Posts` list on t
32
39
The example has some intentionally wonky behavior... when editing the name of a post, there is a decent chance you'll get a random error.
33
40
:::
34
41
35
- <iframe src = " https://codesandbox.io/embed/github/reduxjs/redux-toolkit/tree/feature/v1.6-integration/examples/query/react/optimistic-update?fontsize=12&hidenavigation=1&module=%2Fsrc%2Fapp%2Fservices%2Fposts.ts&theme=dark&runonclick=1"
36
- style = { { width: ' 100%' , height: ' 800px' , border: 0 , borderRadius: ' 4px' , overflow: ' hidden' }}
37
- title = " RTK Query Optimistic Update Example"
38
- allow = " geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
39
- sandbox = " allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
42
+ <iframe
43
+ src = " https://codesandbox.io/embed/github/reduxjs/redux-toolkit/tree/feature/v1.6-integration/examples/query/react/optimistic-update?fontsize=12&hidenavigation=1&module=%2Fsrc%2Fapp%2Fservices%2Fposts.ts&theme=dark&runonclick=1"
44
+ style = { {
45
+ width: ' 100%' ,
46
+ height: ' 800px' ,
47
+ border: 0 ,
48
+ borderRadius: ' 4px' ,
49
+ overflow: ' hidden' ,
50
+ }}
51
+ title = " RTK Query Optimistic Update Example"
52
+ allow = " geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
53
+ sandbox = " allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
40
54
></iframe >
41
55
42
56
## React with GraphQL
43
57
44
- <iframe src = " https://codesandbox.io/embed/rtk-query-graphql-basic-zkqfz?fontsize=12&hidenavigation=1&theme=dark&module=%2Fsrc%2Fapi.js&runonclick=1"
45
- style = { { width: ' 100%' , height: ' 800px' , border: 0 , borderRadius: ' 4px' , overflow: ' hidden' }}
46
- title = " RTK Query GraphQL Example"
47
- allow = " geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
48
- sandbox = " allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
58
+ <iframe
59
+ src = " https://codesandbox.io/embed/rtk-query-graphql-basic-zkqfz?fontsize=12&hidenavigation=1&theme=dark&module=%2Fsrc%2Fapi.js&runonclick=1"
60
+ style = { {
61
+ width: ' 100%' ,
62
+ height: ' 800px' ,
63
+ border: 0 ,
64
+ borderRadius: ' 4px' ,
65
+ overflow: ' hidden' ,
66
+ }}
67
+ title = " RTK Query GraphQL Example"
68
+ allow = " geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
69
+ sandbox = " allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
49
70
></iframe >
50
71
51
72
## Authentication
@@ -56,40 +77,68 @@ There are several ways to handle authentication with RTK Query. This is a very b
56
77
57
78
This example dispatches a ` setCredentials ` action to store the user and token information.
58
79
59
- <iframe src = " https://codesandbox.io/embed/rtk-query-authentication-example-zx8me?fontsize=12&hidenavigation=1&module=%2Fsrc%2Ffeatures%2Fauth%2FauthSlice.tsx&theme=dark&runonclick=1"
60
- style = { { width: ' 100%' , height: ' 800px' , border: 0 , borderRadius: ' 4px' , overflow: ' hidden' }}
61
- title = " RTK Query Authentication Example"
62
- allow = " geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
63
- sandbox = " allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
80
+ <iframe
81
+ src = " https://codesandbox.io/embed/rtk-query-authentication-example-zx8me?fontsize=12&hidenavigation=1&module=%2Fsrc%2Ffeatures%2Fauth%2FauthSlice.tsx&theme=dark&runonclick=1"
82
+ style = { {
83
+ width: ' 100%' ,
84
+ height: ' 800px' ,
85
+ border: 0 ,
86
+ borderRadius: ' 4px' ,
87
+ overflow: ' hidden' ,
88
+ }}
89
+ title = " RTK Query Authentication Example"
90
+ allow = " geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
91
+ sandbox = " allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
64
92
></iframe >
65
93
66
94
### Using ` extraReducers `
67
95
68
96
This example uses a matcher from the endpoint and ` extraReducers ` in the ` authSlice ` .
69
97
70
- <iframe src = " https://codesandbox.io/embed/rtk-query-authentication-example-extrareducers-5w7q9?fontsize=12&hidenavigation=1&module=%2Fsrc%2Ffeatures%2Fauth%2FauthSlice.tsx&theme=dark&runonclick=1"
71
- style = { { width: ' 100%' , height: ' 800px' , border: 0 , borderRadius: ' 4px' , overflow: ' hidden' }}
72
- title = " RTK Query Authentication Example - extraReducers"
73
- allow = " accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking"
74
- sandbox = " allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
98
+ <iframe
99
+ src = " https://codesandbox.io/embed/rtk-query-authentication-example-extrareducers-5w7q9?fontsize=12&hidenavigation=1&module=%2Fsrc%2Ffeatures%2Fauth%2FauthSlice.tsx&theme=dark&runonclick=1"
100
+ style = { {
101
+ width: ' 100%' ,
102
+ height: ' 800px' ,
103
+ border: 0 ,
104
+ borderRadius: ' 4px' ,
105
+ overflow: ' hidden' ,
106
+ }}
107
+ title = " RTK Query Authentication Example - extraReducers"
108
+ allow = " accelerometer; ambient-light-sensor; camera; encrypted-media; geolocation; gyroscope; hid; microphone; midi; payment; usb; vr; xr-spatial-tracking"
109
+ sandbox = " allow-forms allow-modals allow-popups allow-presentation allow-same-origin allow-scripts"
75
110
></iframe >
76
111
77
112
## React Class Components
78
113
79
114
Check out the ` PostDetail ` component for an example of Class Component usage.
80
115
81
- <iframe src = " https://codesandbox.io/embed/react-class-component-example-48hyq?fontsize=12&hidenavigation=1&theme=dark&runonclick=1"
82
- style = { { width: ' 100%' , height: ' 800px' , border: 0 , borderRadius: ' 4px' , overflow: ' hidden' }}
83
- title = " rtk-query-react-hooks-example"
84
- allow = " geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
85
- sandbox = " allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
116
+ <iframe
117
+ src = " https://codesandbox.io/embed/react-class-component-example-48hyq?fontsize=12&hidenavigation=1&theme=dark&runonclick=1"
118
+ style = { {
119
+ width: ' 100%' ,
120
+ height: ' 800px' ,
121
+ border: 0 ,
122
+ borderRadius: ' 4px' ,
123
+ overflow: ' hidden' ,
124
+ }}
125
+ title = " RTK Query React Class Components Example"
126
+ allow = " geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
127
+ sandbox = " allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
86
128
></iframe >
87
129
88
130
## Svelte
89
131
90
- <iframe src = " https://codesandbox.io/embed/svelte-app-rtk-simplequery-demo-f1ueb?fontsize=12&hidenavigation=1&theme=dark&runonclick=1"
91
- style = { { width: ' 100%' , height: ' 800px' , border: 0 , borderRadius: ' 4px' , overflow: ' hidden' }}
92
- title = " rtk-query-svelte-example"
93
- allow = " geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
94
- sandbox = " allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
132
+ <iframe
133
+ src = " https://codesandbox.io/embed/svelte-app-rtk-simplequery-demo-f1ueb?fontsize=12&hidenavigation=1&theme=dark&runonclick=1"
134
+ style = { {
135
+ width: ' 100%' ,
136
+ height: ' 800px' ,
137
+ border: 0 ,
138
+ borderRadius: ' 4px' ,
139
+ overflow: ' hidden' ,
140
+ }}
141
+ title = " RTK Query Svelte Example"
142
+ allow = " geolocation; microphone; camera; midi; vr; accelerometer; gyroscope; payment; ambient-light-sensor; encrypted-media; usb"
143
+ sandbox = " allow-modals allow-forms allow-popups allow-scripts allow-same-origin"
95
144
></iframe >
0 commit comments