Explorar o código

mapDispatchToProps test

serg1557733 hai 1 ano
pai
achega
c349e15281
Modificáronse 1 ficheiros con 6 adicións e 1 borrados
  1. 6 1
      src/components/Counter.js

+ 6 - 1
src/components/Counter.js

@@ -1,5 +1,8 @@
  import { connect } from "react-redux";
  import * as action from '../actions'; 
+ import { bindActionCreators } from "redux";
+
+
 
  const Counter = ({ counter, inc, dec, rnd}) => {
     return (
@@ -19,5 +22,7 @@ const mapStateToProps = (state) => {
         }
     )
 }
+const mapDispatchToProps = (dispatch) => bindActionCreators(action, dispatch)
+
 
-export default connect(mapStateToProps, action )(Counter);
+export default connect(mapStateToProps, mapDispatchToProps )(Counter);