javascript - Navigate in React-Native -


i trying navigate in react-native, source

import react 'react';  import { stacknavigator } 'react-navigation';  import { text, touchableopacity } 'react-native';    import loginform './components/loginform';  import employeelist './components/employeelist';  import employeecreate './components/employeecreate';    const addbutton = (param) => (    <touchableopacity onpress={() => console.log(param)}>      <text style={styles.addbuttonstyle}>add</text>    </touchableopacity>  );    const styles = {    addbuttonstyle: {      fontsize: 18,      marginright: 25,      color: '#007aff'    },    headertitlestyle: {      fontweight: 'normal',      alignself: 'center',      marginleft: 50    }  };    const routercomponent = stacknavigator({    employeelist: {      screen: employeelist,      navigationoptions: {        title: 'employee list',        headertitlestyle: styles.headertitlestyle,        headerleft: null,        headerright: addbutton()      }    },    employeecreate: {      screen: employeecreate,      navigationoptions: {        title: 'employee create'      }    },    home: {      screen: loginform,      navigationoptions: {        title: 'please, log in',        headertitlestyle: styles.headertitlestyle      }    }  });    export default routercomponent;

actually need, it's in const addbutton reach this.props.navigation.navigate('employeecreate'); me able navigate employeecreate addbutton, addbutton doesn't have props. i'm tried throw props parameter in addbutton, nothing happen. know, how fix issue?

in employeelist component in stacknavigator, can define navigationoptions such:

navigationoptions: ({navigation}) =>  return {   title: 'employee list',   headertitlestyle: styles.headertitlestyle,   headerleft: null,   headerright: addbutton(navigation) } 

then in addbutton component, can use navigation.navigate function.


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -