Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User extends Component {
- render() {
- return <div>{this.props.user.name}</div>
- }
- componentWillMountDidMount() {
- this.getUser();
- }
- async getUser() {
- try {
- const user = await userAction.get();
- this.props.storeUser(user);
- } catch (err) {}
- }
- }
- const state2props = (state) => ({
- user: state.User.user
- });
- const dispatch2props = dispatch => ({
- storeUser: (user) => dispatch(userReducer.store(user)),
- });
- export default connect(state2props, dispatch2props)(User);
Add Comment
Please, Sign In to add comment