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.
32 lines
663 B
JavaScript
32 lines
663 B
JavaScript
import Router from 'preact-router'
|
|
import { route } from 'preact-router'
|
|
|
|
import { render } from 'preact'
|
|
import { useEffect } from 'preact/hooks'
|
|
import { DashboardPage, JobsPage } from './pages.jsx'
|
|
|
|
const Redirect = ({ to }) => {
|
|
useEffect(() => {
|
|
console.log('Redirecting...')
|
|
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)
|