React Native: How to redirect -


i'm new react native , don't how react-navigation works. i've spend multiple work days , tried different variants, don't examples https://reactnavigation.org/docs/intro/ work.

my project created create-react-native-app awesomeproject, it's described on react native docs.

so went last working point (without routing).

this file structure:

root - src - - screens - - - loginscreen.js - - - homescreen.js - app.js 

in app.js perform easy call:

import loginscreen './src/screens/loginscreen'; export default loginscreen; 

this simplified version of loginscreen.js:

import react 'react'; import {     stylesheet,     text,     view,     appregistry,     button,     reactnative, } 'react-native';  /**  * actual view  */ class loginscreen extends react.component {     constructor(props) {         super(props);         this.state = {             // values         }     }      render() {         return (                 <view style={[styles.containerone]}>/>                 // input fields                 <button                     onpress={this.loginbuttononpress.bind(this)}                     title="login"                     style={[styles.loginbutton]}                 />             </view>         );     }      loginbuttononpress() {         // validation fetch     } }  export default loginscreen;  /**  * style  */ const styles = stylesheet.create({     containerone: {         margintop: -160,         justifycontent: 'center',         flex: 1,         alignitems: 'center',     }     loginbutton: {         color: 'blue',         margintop: 10,     } }); 

the loginscreen.js should first displayed page. want load homescreen.js file when loginbuttononpress called. how supposed that? i've found like

const simpleapp = stacknavigator({   login: { screen: loginscreen },   home: { screen: homescreen }, }); 

but don't work, too.

i'm thankfull every can get.

press login button go homescreen.

render() {     return (             <view style={[styles.containerone]}>/>             // input fields             <button                 onpress={() => navigation.navigate('home'))}                 title="login"                 style={[styles.loginbutton]}             />         </view>     ); } 

you can try work

app.js

const simpleapp = stacknavigator({   login: { screen: loginscreen },   home: { screen: homescreen }, },{ swipeenabled: false } 

);

export default simpleapp 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -