You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have issue using useRouter hook and matching route params. Returned context from useRouter hook contains only url key at render time. Later it also contains matches key (that I'm interested in), but at this point it does not trigger re-render of component and I'm stuck only with initial context. Don't know if this is issue on my end, because there is no documentation for this hook. Here is dummy code, that has same logic as my project, but this somehow works while my project does not. Any hints?
// DummyComponent.tsximport{FunctionalComponent,h}from"preact";import{useRouter}from"preact-router";constDummyComponent: FunctionalComponent=()=>{const[context]=useRouter();// console.log(JSON.stringify(context), context); // JSON.stringify fails in this dummy component, but works in my project, see screenshot belowreturn(<div>{context?.matches?.permalinkId ? "OK" : "MISSING"}</div>);};exportdefaultDummyComponent;
Hello,
I have issue using
useRouter
hook and matching route params. Returned context fromuseRouter
hook contains onlyurl
key at render time. Later it also containsmatches
key (that I'm interested in), but at this point it does not trigger re-render of component and I'm stuck only with initial context. Don't know if this is issue on my end, because there is no documentation for this hook. Here is dummy code, that has same logic as my project, but this somehow works while my project does not. Any hints?console.log
from my project:Thanks.
The text was updated successfully, but these errors were encountered: