Skip to content

Latest commit

 

History

History
24 lines (18 loc) · 438 Bytes

useMap.md

File metadata and controls

24 lines (18 loc) · 438 Bytes

useMap

React 状态钩子,用于追踪对象型值。

用法

import {useMap} from 'react-use';

const Demo = () => {
  const [map, {set, reset}] = useMap({
    hello: 'there',
  });

  return (
    <div>
      <pre>{JSON.stringify(map, null, 2)}</pre>
      <button onClick={() => set(String(Date.now()), (new Date()).toJSON())}>Add</button>
      <button onClick={() => reset()}>Reset</button>
    </div>
  );
};