Skip to content
This repository has been archived by the owner on Sep 10, 2022. It is now read-only.

Commit

Permalink
Update withState docs
Browse files Browse the repository at this point in the history
  • Loading branch information
acdlite committed Oct 11, 2015
1 parent 7aab08e commit e3f7e17
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ withState(
Passes two additional props to the base component: a state value, and a function to update that state value. The state updater has the following signature:

```js
stateUpdater<T>((prevValue: T) => T): void
stateUpdate(newValue: any): void
stateUpdater<T>((prevValue: T) => T, callback: Function): void
stateUpdate(newValue: any, callback: Function): void
```

The first form accepts a function which maps the previous state value to a new state value. You'll likely want to use this state updater along with `mapProps()` to create specific updater functions. For example, to create an HoC that adds basic counting functionality to a component:
Expand All @@ -138,6 +138,8 @@ const addCounting = compose(

The second form accepts a single value, which is used as the new state.

Both forms accept as second parameter, a callback function that will be executed once `setState()` is completed and the component is re-rendered.

### `withReducer()`

```js
Expand Down

0 comments on commit e3f7e17

Please sign in to comment.