Replies: 1 comment 13 replies
-
This works as expected if the router is a reactive object, e.g. export const router = $state({
path: '/path/to/somewhere?q=wah',
routes: [
{ path: '/path/to/somewhere' },
{ path: '/path/to/elsewhere' },
],
}); You can check whether the values actually update inside the function using $inspect(path, search.toString(), matched) |
Beta Was this translation helpful? Give feedback.
13 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
For example, the
useRoute
function here was originally expected to return a large object, but it seems to have lost its reactivity. I tried creating a large object to return, or replacing the function with a getter property, but neither worked correctly... I wonder if it's possible to maintain the expected function interface when using rune.I found a strange but effective method, mainly with two problems
$derived(useRoute())
be changed touseRoute()
while still maintaining reactivity?It seems that it can be written this way, but I want to know why
$state
can be returned in the function while$derived
cannot?The best method found so far seems to be placing a reactive value in the get, so that the places where it is referenced will also remain reactive.
Beta Was this translation helpful? Give feedback.
All reactions