Solution to what I had seen as a bug.

This commit is contained in:
Eric van der Vlist 2022-11-25 15:55:03 +01:00
parent 1548e81f13
commit 63e5076211
1 changed files with 9 additions and 5 deletions

View File

@ -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>
),