reactjs - connect react sfc component to redux and pass actions to it -
//test.js let test=() =>{ const handleclick=()=>{ console.log(props); this.props.addtodos('toto');// fail undefined props.addtodos('toto'); // fail props undefined } return ( <div> <button type="submit" onclick={handleclick} classname="btn btn-primary btn-md">submit</button> </div> ) } const mapdispatchtoprops = (dispatch) => { return { addtodos:addtodo } } test = connect( null, mapdispatchtoprops )(test) export default test; //actions.js import { createaction } 'redux-actions'; const add_todo='add_todo'; export const addtodo = createaction(add_todo);
i'm trying connect sfc component redux , pass actions access them it, not work. , props undefined. how can achieve ?
Comments
Post a Comment