|
|
@ -1,6 +1,6 @@ |
|
|
|
/* @refresh reload */ |
|
|
|
import { render } from 'solid-js/web'; |
|
|
|
import type { Component } from 'solid-js'; |
|
|
|
import { Component, createEffect, createSignal, onMount } from 'solid-js'; |
|
|
|
|
|
|
|
import { |
|
|
|
Router, |
|
|
@ -10,15 +10,19 @@ import { |
|
|
|
useParams, |
|
|
|
useNavigate, |
|
|
|
hashIntegration, |
|
|
|
useRouteData, |
|
|
|
} from '@solidjs/router'; |
|
|
|
|
|
|
|
const Counter: Component = () => { |
|
|
|
const params = useParams(); |
|
|
|
const count = +params.count; |
|
|
|
const [count, setCount] = createSignal(0); |
|
|
|
createEffect(() => { |
|
|
|
setCount(+params.count); |
|
|
|
}); |
|
|
|
const navigate = useNavigate(); |
|
|
|
return ( |
|
|
|
<> |
|
|
|
<button onClick={() => navigate(`/counter/${count + 1}`)}>+1</button> |
|
|
|
<button onClick={() => navigate(`/counter/${count() + 1}`)}>+1</button> |
|
|
|
<div>Count: {count}</div> |
|
|
|
</> |
|
|
|
); |
|
|
@ -32,10 +36,10 @@ const App: Component = () => { |
|
|
|
</Routes> |
|
|
|
); |
|
|
|
}; |
|
|
|
|
|
|
|
// source={hashIntegration()}
|
|
|
|
render( |
|
|
|
() => ( |
|
|
|
<Router source={hashIntegration()}> |
|
|
|
<Router > |
|
|
|
<App /> |
|
|
|
</Router> |
|
|
|
), |
|
|
|