navigation - react native navigator push undefined crash first route -
index.ios.js
render: function() { return ( <navigatorios style={styles.navigationcontainer} initialroute={{ title: "stories", component: stories, leftbuttontitle : 'blabla', rightbuttontitle : 'profile', onleftbuttonpress: () => { // this.blabla() }, onrightbuttonpress: () => { this.goprofile(); } }} /> ); } goprofile function
goprofile : function () { this.props.navigator.push({ title: 'profile', component: profilepage, leftbuttontitle: 'home', }); }, cannot read property 'push' of undefined object props have roottag in object. why crash on first page application .
try adding navigator reference:
ref="navigator"
and pushing refs instead of props:
goprofile : function () { this.refs.navigator.push({ title: 'profile', component: profilepage, leftbuttontitle: 'home', }); }, so, navigatorios should this:
<navigatorios ref="navigator" style={styles.navigationcontainer} initialroute={{ title: "stories", component: stories, leftbuttontitle : 'blabla', rightbuttontitle : 'profile', onleftbuttonpress: () => { // this.blabla() }, onrightbuttonpress: () => { this.goprofile(); } }} />
Comments
Post a Comment