skip to Main Content

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


  1. You should use react native navigation in react native project.
    https://reactnavigation.org/docs/hello-react-navigation

    Login or Signup to reply.
  2. Create the pages in the app directory. Something like this:

    app
      index.tsx
      instructions.tsx
    

    Navigate from index:

    router.replace('/instructions');
    

    See Create pages with Expo Router for details.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search