From c520797fd5756cb94892dfe87974ffb6f6b93d65 Mon Sep 17 00:00:00 2001 From: Arty Date: Sun, 6 Oct 2019 22:02:45 -0700 Subject: [PATCH] docs: useMap demo link + improved docs (#650) * improve docs: useMap demo link * improve docs: useMap demo link (remove callback usage added) * Add remove action to useMap story --- README.md | 2 +- docs/useMap.md | 14 ++++++++++---- src/__stories__/useMap.story.tsx | 7 +++++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 166a8515..b8ffca34 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ - [`useToggle` and `useBoolean`](./docs/useToggle.md) — tracks state of a boolean. [![][img-demo]](https://codesandbox.io/s/focused-sammet-brw2d) - [`useCounter` and `useNumber`](./docs/useCounter.md) — tracks state of a number. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/state-usecounter--demo) - [`useList`](./docs/useList.md) — tracks state of an array. - - [`useMap`](./docs/useMap.md) — tracks state of an object. + - [`useMap`](./docs/useMap.md) — tracks state of an object. [![][img-demo]](https://codesandbox.io/s/quirky-dewdney-gi161)
diff --git a/docs/useMap.md b/docs/useMap.md index 99e5e131..cf3273af 100644 --- a/docs/useMap.md +++ b/docs/useMap.md @@ -2,22 +2,28 @@ React state hook that tracks a value of an object. - ## Usage ```jsx import {useMap} from 'react-use'; const Demo = () => { - const [map, {set, reset}] = useMap({ + const [map, {set, remove, reset}] = useMap({ hello: 'there', }); return (
+ + +
{JSON.stringify(map, null, 2)}
- -
); }; diff --git a/src/__stories__/useMap.story.tsx b/src/__stories__/useMap.story.tsx index 83c2b95e..1e5d085f 100644 --- a/src/__stories__/useMap.story.tsx +++ b/src/__stories__/useMap.story.tsx @@ -4,15 +4,18 @@ import { useMap } from '..'; import ShowDocs from './util/ShowDocs'; const Demo = () => { - const [map, { set, reset }] = useMap({ + const [map, { set, remove, reset }] = useMap({ hello: 'there', }); return (
-
{JSON.stringify(map, null, 2)}
+ +
{JSON.stringify(map, null, 2)}
); };