javascript - React native connect function not passing action to child component through props -


i getting familiarized redux , have been reading supposed pass in action creators through parent of app, , through mapstatetoprops, mapdispatchtoprops, , connect function should able pass actions. however, when call in child component this.props. function nonexistent, seems not being passed properly.

i appreciate assistance.

note: left out things imports , reducer more concise.

login.js:

export function login(token, id) {   console.log('login action');   return {     type: 'log_in',     token,     id,   }; } 

index.ios.js:

import * actioncreators './actions/login'  const store = createstore(rootreducer, undefined, autorehydrate()); persiststore(store);  class app extends component {   constructor(props) {     super(props);     state = {       token: '',       id: '',       store: store,     };   }    render() {         return (      <provider store={ state.store }>       <view style = {styles.container}>         <loginview/>       </view>     </provider>     );   } }  appregistry.registercomponent('app', () => app);   function mapstatetoprops(state) {   return {     token: state.token,     id: state.id   } }  function mapdispatchtoprops(dispatch) {   return bindactioncreators({actioncreators}, dispatch); }  export default connect(mapstatetoprops, mapdispatchtoprops)(app); 

loginview.js:

export class loginview extends view {    static proptypes = {}    static defaultprops = {}    constructor(props) {     console.log(props);     super(props)     this.state = {       user: '',       token: '',       id: '',     }     this.onlogin = this.onlogin.bind(this);   }    onlogin() {     console.log("on login1");     this.props.login({token: this.state.token, id: this.state.id});     console.log("on login");   } 

and happens when onlogin() function evoked directly above, states this.props.login not function. reasoning , how can fix it?

you're connecting app component, have this.props.onlogin(). however, you're not passing onlogin prop <loginview />. need either render <loginview onlogin={this.props.onlogin} />, or connect loginview , include onlogin part of component's connection.


Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -