File tree Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Expand file tree Collapse file tree 2 files changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -170,7 +170,7 @@ function AppWithExampleInURL(props: AppProps) {
170
170
171
171
const selectedExample = urlParams . name
172
172
? examples . find ( ( { name } ) => urlParams . name === name )
173
- : examples [ examples . length - 1 ] ;
173
+ : props . examples [ props . examples . length - 1 ] ;
174
174
175
175
const changeExample = useCallback (
176
176
( example : ReactExampleDescription ) => {
@@ -191,15 +191,16 @@ function AppWithExampleInURL(props: AppProps) {
191
191
useEffect ( ( ) => {
192
192
if ( selectedExample ) {
193
193
props . changeExample ( selectedExample ) ;
194
+ } else {
195
+ history . push ( '/' ) ;
194
196
}
195
- } , [ selectedExample ] ) ;
197
+ } , [ selectedExample , history ] ) ;
196
198
197
199
// If name is invalid, redirect to home
198
200
if ( ! selectedExample ) {
199
201
console . error (
200
202
`Could not find an example with name "${ urlParams . name } ", redirecting to /`
201
203
) ;
202
- history . push ( '/' ) ;
203
204
return null ;
204
205
}
205
206
Original file line number Diff line number Diff line change 27
27
*/
28
28
import ReactDOM from 'react-dom' ;
29
29
import {
30
- BrowserRouter as Router ,
30
+ HashRouter as Router ,
31
31
Switch ,
32
32
Redirect ,
33
33
Route ,
You can’t perform that action at this time.
0 commit comments