简体   繁体   中英

Navigate to another screen with react-native-navigation

Good afternoon everyone. I'm a little bit stucked with a navigation on button click.

I would like to move to another screen on a button click

Button code part (./Components/Dashboard.js):

<List>
  <ListItem avatar>
    <Left>
      <Thumbnail source={{ uri: 'image-url' }} />
    </Left>
    <Body>
      <Button dark transparent>
        <Text>Euro</Text>
        <Text>4200</Text>
      </Button>
    </Body>
  </ListItem>
</List>

And I have a new screen with few buttons (./Components/Screens/EuroScreen.js)

import * as React from 'react';
import { Button, View, Text } from 'react-native';
function HomeScreen({ navigation }) {
  return (
    <View style={{ flex: 1, alignItems: 'center', justifyContent: 'center'}}>
      <Text>Euro Screen</Text>
      <Button dark>Test</Button>
    </View>
  );
}

How I can add a click property to my Button in ./Components/Dashboard ?

This might help

Dashboard({ navigation }) {
    return (
      <View>
        <List>
          <ListItem avatar>
            <Left>
              <Thumbnail source={{ uri: "image-url" }} />
            </Left>
            <Body>
              <Button onPress={() => navigation.navigate("EuroScreen")}>
                <Text>Euro</Text>
                <Text>4200</Text>
              </Button>
            </Body>
          </ListItem>
        </List>
      </View>
    );
  }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM