Reputation: 13296
I am using preact-router in a project. I got it working nicely, depending on the URL different components get rendered.
Now a component needs to access to add a /path to the url. Is there a way to do this? Documentation is unfortunately lacking.
I have tried to just modify the components props, hoping there would be some kind of two-way-binding, but no chance. Then I looked up the Browser History API, but I am not sure if this is the right path since it's something like a router.
Upvotes: 3
Views: 1162
Reputation: 303
So preact-router
does not give you a two way binding. It rather gives you a route
method and here's how you use it
import {h, Component} from 'preact';
import {route} from 'preact-router';
export default MyComponent extends Component{
render(props) {
// do your logic or jsx here...
route(props.path + '/path');
}
}
Upvotes: 2