Skip to content

Instantly share code, notes, and snippets.

@webdevstar
Last active November 9, 2018 02:14
Show Gist options
  • Save webdevstar/c867e6bc206653a907e0ffadd1db1330 to your computer and use it in GitHub Desktop.
Save webdevstar/c867e6bc206653a907e0ffadd1db1330 to your computer and use it in GitHub Desktop.
Redux connect example (dispatch & state)
import action from "../../Actions/MyAction";
import Cartbox from "./Cartbox";
import {bindActionCreators} from "redux";
import {connect} from "react-redux";
class Header extends Component {
constructor(props) {
super(props);
}
render () {
var carts = this.props.cart;
this.props.Action("1111");
return (
<div>
{
carts.map((cart) =>
<Cartbox key={cart.id} cart={cart}/>
)
}
</div>
);
}
}
const mapDispatchToProps = (dispatch) => {
return {
Action : (e) => dispatch(action(e))
}
}
const MyStatelessComponent = (state) => {
return (
cart: state.cart
)
}
const WrappedComponent = connect(mapStateToProps, mapDispatchToProps)(Component);
@kinddeveloper
Copy link

understood.
I have fixed redux connect issue.
Thanks

@nodetop
Copy link

nodetop commented Oct 3, 2018

I know redux connect way now.

@filip1991903
Copy link

download

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment