javascript - undefined is not an object (evaluating 'this.props.navigator.push') react native -


i have issue. went through other post couldnt me. have herewith attached code. problem when try navigate in searchlead.js , gives me same error undefined not object (evaluating 'this.props.navigator.push') . appreciate help.

index.ios.js

'use strict'; import react, { component } 'react'; import {  appregistry,  stylesheet,  text,  textinput,  touchablehighlight,  view,  asyncstorage,  alertios,  navigator }from 'react-native'; var login = require('./login'); var afterloginview = require('./afterloginview'); var searchlead = require('./searchlead'); var renderdetails = require('./renderdetails'); class ehnyapp extends component { componentwillunmount() { actions.currentrouter = null } renderscene(route,navigator){ if(route.name == 'login'){ return <login navigator = {navigator} /> } if(route.name == 'afterlogin'){ return <afterloginview navigator = {navigator} /> } if(route.name == 'search'){ return <searchlead navigator = {navigator} /> } if(route.name == 'renderdetails'){ return <renderdetails navigator = {navigator} /> } } render() { return (     <navigator           initialroute = {{ name: 'login' }}           renderscene = {this.renderscene.bind(this)}       />  ); } } appregistry.registercomponent('ehnyapp', () => ehnyapp); 

login.js

    'use strict';     import react, { component } 'react';     import {     appregistry,             stylesheet,             text,             textinput,             touchablehighlight,             view,             asyncstorage,             alertios,             navigatorios,             image,             activityindicatorios              } 'react-native';     var afterloginview = require('./afterloginview');     var storage_key = 'id_token';     class login extends component{     constructor(props){     super(props)             this.state = {             username : '',                     password : '',                     errormesage  : '',                     isloading : false,             }     }      submitform(event){                  this.setstate({ isloading: true });                    this.swipetoafterloginview('afterlogin');     }      swipetoafterloginview(routename){             this.props.navigator.push({             name : routename,           });     }     render() {     var spinner = this.state.isloading ? ( <activityindicatorios hidden = 'true' size = 'large'/> ) :             <view/>             return (                     <view style = {styles.container}>                     <view style = {styles.logo}>                     <image style = {styles.logoimage}             source = {require('./logo.png')}             resizemode = 'contain'                     />                     </view>             {spinner}             <view style = {styles.containerfirst}>                     <text style = {styles.errormesage}> { this.state.errormesage } </text>                      <textinput style = {styles.textinput}             placeholder = 'email'                     placeholdertextcolor = 'white'                     autofocus = {true}             autocapitalize = 'none'                     onchange = {this.usernameinput.bind(this)}          />                        </view>                     <view style = {styles.containersecond}>                     <textinput ref = 'password' placeholdertextcolor = 'white'                     value = { this.state.password}             onchangetext = {password => this.setstate({password})}             onsubmitediting = {this._submitform}             style = {styles.textinput}             placeholder = 'password'                     autocapitalize = 'none'                     password = {true}             />                     </view>                     <touchablehighlight                     style = {styles.button}   onpress = {this.submitform.bind(this)}>                     <text style = {styles.buttontext}> login </text>                     </touchablehighlight>                      <text style = {styles.forgotpassword}> forgot password ? </text>                      </view>                     );     }      }     module.exports = login; 

afterloginview.js

    'use strict';     import react, { component } 'react';     import {     appregistry,             stylesheet,             text,             textinput,             touchablehighlight,             view,             asyncstorage,             alertios,             navigator,             tabbarios,             activityindicatorios             } 'react-native';     var dashboard = require('./dashboard');     var other = require('./other');     var searchlead = require('./searchlead');     class afterloginview extends component{     constructor(props) {     super(props);             this.state = {             selectedtab:'searchlead',                     isloading : false,             };     }     render(){     var spinner = this.state.isloading ?             ( <activityindicatorios                     hidden = 'true'                     size = 'large'/> ) :             ( <view/> );             return (                     <tabbarios selectedtab = {this.state.selectedtab}>                     <tabbarios.item                     selected = {this.state.selectedtab === 'searchlead'}             title = 'searchlead'                     systemicon = 'search'                     onpress = { () => {                     this.setstate({                     selectedtab : 'searchlead'                     })                     }} >                     <searchlead/>                     </tabbarios.item>                     <tabbarios.item                     selected = {this.state.selectedtab === 'dashboard'}             //systemicon="featured"             title = 'dashboard'                     onpress = {() => {                     this.setstate({                     selectedtab :'dashboard'                     });                     }}>                     <dashboard/ >                     </tabbarios.item>                     <tabbarios.item                     selected = {this.state.selectedtab === 'other'}             title = 'other'                     onpress = {() => {                     this.setstate({                     selectedtab : 'other'                     });                     }} >                     <other/>                     </tabbarios.item>                     </tabbarios>                         );     }     async submitform(event){      var demotoken = await asyncstorage.getitem('id_token');             console.log(demotoken);             // this.login();     }       };     module.exports = afterloginview;` 

searchlead.js

    'use strict';     import react, { component } 'react';     import {     appregistry,             stylesheet,             text,             textinput,             listview,             view,             touchablehighlight,             navigator             } 'react-native';     var renderdetails = require('./renderdetails');     var login = require('./login');     var ds = new listview.datasource({rowhaschanged: (r1, r2) => r1 !== r2});     class searchlead extends component {     constructor(props) {     super(props);             this.state = {             searchedadresses: []             };     };             componentwillmount = function(){             this._pressdata = {};             }     _pressdata = function (){     console.log("yes");     }     searchedadresses = (searchedtext) => {     if (searchedtext === '') {     return [];     }     var url = 'https://maps.googleapis.com/maps/api/place/autocomplete/json?input=' + searchedtext + '&types=geocode&key=apikeuys-s&sensor=true';             var = 0;             var addressdata = new array();             fetch(url, { method:"get"})             .then((response) = > response.json())             .then((responsedata) = > {             (i = 0; < responsedata.predictions.length; i++){             addressdata[i] = {description : responsedata.predictions[i].description, place_id :  responsedata.predictions[i].place_id };             }             this.setstate({searchedadresses: addressdata});             })             .done();     };             renderadress = (rowdata, sectionid, rowid) => {      return (             <touchablehighlight  onpress = { this._onpressaddresslist.bind(this)} underlaycolor = 'white'>             <text style = { styles.listtextinput }> {rowdata.description} </text>              </touchablehighlight>             );     };             _onpressaddresslist = () => {     this.props.navigator.push({     name:'renderdetails'  });     }     _renderseperator(sectionid: number, rowid: number, adjacentrowhighlighted: bool) {     return (             <view key = {`${sectionid} - ${rowid}`} style = {{ height: adjacentrowhighlighted ? 4 : 1, backgroundcolor: adjacentrowhighlighted ? '#3b5998' : '#cccccc', }}     />              );     }     render() {     return (             <view style = {styles.container}>             <view style = {styles.imagecontainer}> </view>             <view style = {styles.textcontainer}>             <textinput             style = {styles.textinput}     onchangetext = {this.searchedadresses}     placeholder = "type adress here"/>             </view>             <view >             <listview             datasource = {ds.clonewithrows(this.state.searchedadresses)}     renderrow = {this.renderadress}     renderseparator = {this._renderseperator}     enableemptysections = {true}     />             </view>             </view>             );     };             }     module.exports = searchlead;` 

note:disregard stylesheet!! went through following post didnt me.

https://github.com/facebook/react-native/issues/416

undefined not object (evaluating 'this.props.navigator.push')


Comments