_layout.js
import { GestureHandlerRootView } from "react-native-gesture-handler"
import { Drawer } from "expo-router/drawer"
export default function Layout() {
return (
<GestureHandlerRootView style={{ flex: 1 }}>
<Drawer>
<Drawer.Screen
name="index" // This is the name of the page and must match the url from root
options={{
drawerLabel: "Home",
title: "",
}}
/>
<Drawer.Screen
name="hackernews" // This is the name of the page and must match the url from root
options={{
drawerLabel: "HackerNews",
title: "",
}}
/>
<Drawer.Screen
name="more" // This is the name of the page and must match the url from root
options={{
drawerLabel: "More",
title: "",
}}
/>
<Drawer.Screen
name="securestore" // This is the name of the page and must match the url from root
options={{
drawerLabel: "secureStore",
title: "",
}}
/>
</Drawer>
</GestureHandlerRootView>
)
}
hackernews.js
import { React } from "react"
import { StyleSheet } from "react-native"
import { WebView } from "react-native-webview"
export default function Page() {
return (
<WebView
style={styles.container}
source={{ uri: "https://news.ycombinator.com/login" }}
injectedJavaScriptBeforeContentLoaded={`
document.getElementsByName("acct")[0].value="testLogin"
document.getElementsByName("pw")[0].value="testPassword"
document.getElementsByTagName("input")[2].click()
`}
/>
)
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: "#fff",
alignItems: "center",
justifyContent: "center",
},
})
Hi I want to build autologin functionality for some websites using expo's WebView. I have two problems right now. 1. When I first time go to hackernews from my drawer I automatically login as planned, but when I manually log out and try to change drawer tab and go back I do not login again. 2. When I click on some link on hackernews I have no possibility of going back to hackernews main page. Below code including layout and hackernews WebView component.