Reputation: 9467
I have the following RN code in my project. I want to navigate to a screen from where I have commented. Im inside a webview and if a condition is true, I want to navigate to a specific screen. Is there any way I can achieve this?
class CitizenLoginWebView extends Component {
render() {
return (
<WebView
source={{uri: citizenLoginUrl}}
onNavigationStateChange={navState => {
if (navState.title === "Consent Platform") {
if (hasWordsInString(navState.url, searchWords)) {
// WANT TO NAVIGATE TO A SCREEN FROM HERE
console.log('Words found');
}
}
}}
/>
);
}
}
Upvotes: 0
Views: 662
Reputation: 137
class CitizenLoginWebView extends Component {
render() {
return (
<WebView
ref={'webview'}
source={{uri: citizenLoginUrl}}
onNavigationStateChange={navState => {
if (navState.title === "Consent Platform") {
if (hasWordsInString(navState.url, searchWords)) {
this.refs.webview.stopLoading();
this.props.navigation.navigate(screen);
console.log('Words found');
}
}
}}
/>
);
}
}
This would work if you use React-Navigation
Upvotes: 1