You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add `loadingContext.done()` at the end of your initial loading method in components that mentioned in routes with `loading` prop (in this case it's `Page1`)
You can specify loading screen that would be shown at the first loading of your app
131
+
You can specify loading screen that will be shown at the first loading of your app
96
132
```js
97
133
constMyLoadingScreen= () =><div>Loading...</div>
98
134
99
-
<Switch loadingScreen={MyLoadingScreen}>
135
+
<Routes loadingScreen={MyLoadingScreen}>// or <Switch>
100
136
...
101
-
</Switch>
137
+
</Routes>
102
138
```
103
139
104
140
Use `maxLoadingTime` property if you want to limit loading time. Pages will switch if loading takes more time than specified in this property (ms).
105
141
```js
106
-
<Switch maxLoadingTime={500}>
142
+
143
+
<Routes maxLoadingTime={500}>// or <Switch>
107
144
...
108
-
</Switch>
145
+
</Routes>
109
146
```
110
147
111
-
If you want to change LoadingContext globally you can pass `isLoading` property to the Switch. This way you don't need to add extra `loadingContext.done();` in your page components after fetching is done.
148
+
If you want to change LoadingContext globally you can pass `isLoading` property to the `<Routes />` or `<Switch />`. This way you don't need to add extra `loadingContext.done();` in your page components after fetching is done.
112
149
```js
113
150
import { useIsFetching } from'react-query';
114
151
constisFetching=useIsFetching();
115
152
116
-
<Switch isLoading={isFetching}>
153
+
<Routes isLoading={isFetching}>// or <Switch>
117
154
...
118
-
</Switch>
155
+
</Routes>
119
156
```
120
157
121
158
Call `topbar.config()` if you want to change topbar configuration. More info <ahref="http://buunguyen.github.io/topbar/"target="_blank">here</a>.
@@ -135,12 +172,30 @@ topbar.config({
135
172
className:'topbar'
136
173
});
137
174
```
138
-
## How to run example on localhost
175
+
#Development
139
176
140
177
Clone repository and run
178
+
```sh
179
+
# go to lib folder
180
+
cd packages/react-router-loading
181
+
182
+
# restore packages
183
+
yarn
184
+
185
+
# build lib
186
+
yarn build
187
+
188
+
# go to example folder
189
+
cd ../../examples/react-router-6
190
+
191
+
# restore packages
192
+
yarn
193
+
194
+
# run example
195
+
yarn dev
141
196
```
142
-
yarn build && yarn start
143
-
```
197
+
198
+
run `yarn build` in lib folder each time you want to apply changes
0 commit comments