I have an app that has a WebView and a bottom navigation bar.
Back, forward and reload buttons work ok since there are goForward(), goBack() and reload() method.
But I also have a home button that should load the starting url.
I tried setting the new url with this.setState
but it doesn't work.
this.setState({
...this.state,
url: DEFAULT_URL,
})
Actually it works the first time. For example if I change the URL in the source and hot reload then it works. But if I click on any link home doesn't work anymore.
Is it possible to do this and if so what am I doing wrong?
I solved it by appending timestamp to url because it seems setting a "new" url triggers the new render() or something.
So the function now goes like this:
this.setState({ url: `${DEFAULT_URL}?t=${Date.now()}` })
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With