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
Is it possible to allow the URL to change, but leave the content of the router as is. For example, if I have the following code to show content outside of the router dependent on the path (think Twitter's old design, where tweets would open over top of the content you was looking at, but still changed the URL)
/** Re-render children with a new URL to match against. */
routeTo(url) {
let matchingRoute = this._getMatchingChild(toChildArray(this.props.children), url)
if (matchingRoute === undefined) return false;
if (matchingRoute[0].props && matchingRoute[0].props.prevent) return true;
this.setState({ url });
// trigger a manual re-route if we're not in the middle of an update:
if (!this._updating) this.forceUpdate();
return true;
},
What you want to do is route the new URL to the same component is all, and handle the changed router state from there. You can't skip the router without making the new URL unusable. For example,
import{Router}from'preact-router';functionExampleRoute({ optionalId }){return(<div>{optionalId&&<h1>Pretend I'm an overlay</h1>}<h1>Show overlay via link</h1><ahref="/12345">Click here</a></div>);}exportfunctionApp(){return(<div><Router><ExampleRoutepath="/:optionalId?"/></Router></div>);}
Hello,
Is it possible to allow the URL to change, but leave the content of the router as is. For example, if I have the following code to show content outside of the router dependent on the path (think Twitter's old design, where tweets would open over top of the content you was looking at, but still changed the URL)
Maybe something like
onChange
that's for exampleor:
The text was updated successfully, but these errors were encountered: