You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
571 B
React
30 lines
571 B
React
2 years ago
|
import Router from 'preact-router'
|
||
|
import { route } from 'preact-router'
|
||
|
|
||
|
import { render } from 'preact'
|
||
|
import { useEffect } from 'preact/hooks'
|
||
|
|
||
|
const Redirect = ({ to }) => {
|
||
|
useEffect(() => {
|
||
|
route(to, true)
|
||
|
}, [])
|
||
|
|
||
|
return (
|
||
|
<>
|
||
|
Redirecting to <pre>{to}</pre>...
|
||
|
</>
|
||
|
)
|
||
|
}
|
||
|
|
||
|
const App = () => {
|
||
|
return (
|
||
|
<Router>
|
||
|
<DashboardPage path="/dashboard" />
|
||
|
<JobsPage path="/jobs" />
|
||
|
<Redirect default to="/dashboard" />
|
||
|
</Router>
|
||
|
)
|
||
|
}
|
||
|
|
||
|
render(<App />, document.body)
|