Skip to content

Commit

Permalink
Improve readme
Browse files Browse the repository at this point in the history
  • Loading branch information
RichardLindhout committed Jun 1, 2020
1 parent fc6860a commit 70dbc15
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,17 @@ cartProductsState.get();

```typescript
import { cartProductsState } from "../cartProductsStatee";

// simple and direct
cartProductsState.set([{ id: 1, name: "NiceProduct" }]);

// if you want previous state
// if you want previous state as callback
cartProductsState.set((prevState) => [
...prevState,
{ id: 1, name: "NiceProduct" },
]);

// if you want want to be sure state is rendered everywhere
// you can also use a callback so you know when state has rendered
cartProductsState.set(
(prevState) => [...prevState, { id: 1, name: "NiceProduct" }],
(newState) => {
Expand Down

0 comments on commit 70dbc15

Please sign in to comment.