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

Commit

Permalink
Merge pull request #2 from hvolschenk/fix/usage
Browse files Browse the repository at this point in the history
fix: update usage instructions
  • Loading branch information
hvolschenk authored Oct 27, 2017
2 parents 6163180 + dbe9412 commit 7f7f578
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,26 @@ import action from 'payload-action-creator';
export const PRODUCTS_FETCHED = 'PRODUCTS_FETCHED';
export const productsFetched = action(PRODUCTS_FETCHED);
```

Now you can dispatch the action from a connected container in your application:

```js
import { connect } from 'react-redux';
import { productsFetched } from './actions';
import Component from './component';

const mapDispatchToProps = dispatch => ({
products: payload => dispatch(productsFetched(payload)),
});

export default connect(undefined, mapDispatchToProps)(Component);
```

The action creator will create an object like so:

```
{
payload: thePayloadYouPassedIn,
type: PRODUCTS_FETCHED,
}
```

0 comments on commit 7f7f578

Please sign in to comment.