Skip to content

Commit 4cffab0

Browse files
authored
Merge pull request #83 from headwirecom/bug/github-pages-router
Switch to hash router so that github pages + base tag works
2 parents c42d77f + 4670190 commit 4cffab0

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

packages/example/src/App.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ function AppWithExampleInURL(props: AppProps) {
170170

171171
const selectedExample = urlParams.name
172172
? examples.find(({ name }) => urlParams.name === name)
173-
: examples[examples.length - 1];
173+
: props.examples[props.examples.length - 1];
174174

175175
const changeExample = useCallback(
176176
(example: ReactExampleDescription) => {
@@ -191,15 +191,16 @@ function AppWithExampleInURL(props: AppProps) {
191191
useEffect(() => {
192192
if (selectedExample) {
193193
props.changeExample(selectedExample);
194+
} else {
195+
history.push('/');
194196
}
195-
}, [selectedExample]);
197+
}, [selectedExample, history]);
196198

197199
// If name is invalid, redirect to home
198200
if (!selectedExample) {
199201
console.error(
200202
`Could not find an example with name "${urlParams.name}", redirecting to /`
201203
);
202-
history.push('/');
203204
return null;
204205
}
205206

packages/example/src/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*/
2828
import ReactDOM from 'react-dom';
2929
import {
30-
BrowserRouter as Router,
30+
HashRouter as Router,
3131
Switch,
3232
Redirect,
3333
Route,

0 commit comments

Comments
 (0)