Reputation: 11
I have searched on google but I don't know react.
When I click on the button 'Connexion' I would like to be forwarded to the page About.js.
My app.js :
import React from 'react';
import {View, TextInput, StyleSheet, Text } from 'react-native';
import { Header, Button } from 'react-native-elements';
import About from './component/About';
export default class App extends React.Component {
render() {
return (
<View style={{flex: 1}}>
<Button
title="CONNEXION"
buttonStyle={{backgroundColor: "#F1C40F", borderColor: "transparent", marginTop: 20,}}
/>
</View>
);
}
}
My About.js
import React from 'react';
import {Text, View, StyleSheet } from 'react-native';
export default class About extends React.Component{
render() {
return (
<View style={style.view}>
<Text style={style.title}> A propos de moi</Text>
</View>
);
}
}
});
Upvotes: 1
Views: 5560
Reputation: 86
or with npm
Inside your index.js, import StackNavigator
import App from './components/app;
import About1 from './components/About;
import {StackNavigator} from 'react-navigation';
Then add below code to the last of index.js
export default StackNavigator({
Home: {
screen: App,
},
Aboutsss:{
screen: About1,
},
});
Inside app.js, inside button give,
onPress = {this.props.navigation.navigate('Aboutsss')}
Hope you understand and if any doubt feel free to comment. note:- when I try to install using npm I got some error in windows, but no problem with yarn.
Upvotes: 3
Reputation: 711
To navigate between the screens you can use stackNavigator.
https://facebook.github.io/react-native/docs/navigation.html
Upvotes: 0