Reputation: 518
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?
Upvotes: 8
Views: 12580
Reputation: 518
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()}` })
Upvotes: 15