Skip to content
This repository has been archived by the owner on Mar 15, 2018. It is now read-only.

How to receive props in createContainer #72

Open
gocreating opened this issue Mar 2, 2017 · 0 comments
Open

How to receive props in createContainer #72

gocreating opened this issue Mar 2, 2017 · 0 comments

Comments

@gocreating
Copy link

gocreating commented Mar 2, 2017

How can I receive props from parent component (actually from redux store's connect HOC) inside Transmit.createContainer?

Given a scenario like below:

// UserList.js

class UserList extends Component {
  render () {
    return this.props.users.map(/* ... */);
  }
}

export default Transmit.createContainer(UserList, {
  /* how to receive props (page, dispatch, foo, bar, ...etc.) here? */
  fragments: {
    users (queryParams) {
      return () => userAPI.list({
         page: pageFromProps, // fetch data depending on props
      }).then(users => {
        dispatchFromProps(receiveUsers(users)); // dispatch action creator to update store
        return users;
      });
    },
  },
});
// MainPage.js

class MainPage extends Component {
  render() {
    return (
      <div>
        <UserList
          page={3}
          dispatch={reduxStore.dispatch}
          foo={reduxStore.getState().foo}
          bar={reduxStore.getState().bar}
        />
      </div>
    );
  }
}
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant