Hello, I have a project structured like the picture. I want to go from GetStarted.js to Instruction.js. I’m using the following code:
<View>
<TouchableOpacity style={styles.button}
onPress={() => router.push('./Instructions.js')}
>
<Text style={styles.buttonText}>
Welcome
</Text>
</TouchableOpacity>
</View>
but I get an Unmatched Route error. I’ve tried with differents folders and it works.
I don’t understand which one is the correct code to switch to a file.js in the same folder. (In this case ‘components’.
I’m pretty sure it’s a simple solution but I can’t find it.
2
Answers
You should use react native navigation in react native project.
https://reactnavigation.org/docs/hello-react-navigation
Create the pages in the
app
directory. Something like this:Navigate from index:
See Create pages with Expo Router for details.