diff --git a/README.md b/README.md index 3751eb5b..62d34545 100644 --- a/README.md +++ b/README.md @@ -118,32 +118,22 @@ - [`useCounter` and `useNumber`](./docs/useCounter.md) — tracks state of a number. - [`useList`](./docs/useList.md) — tracks state of an array. - [`useMap`](./docs/useMap.md) — tracks state of an object. -
-
-
-
-
+## Usage -

Usage

+You need to have React [`16.8.0`](https://reactjs.org/blog/2019/02/06/react-v16.8.0.html) or later installed to use the Hooks API. You can import each hook individually -
+```js +import useToggle from 'react-use/lib/useToggle' +``` -

-You need to have React 16.8.1 or later installed to use Hooks API. -

+or use ES6 named imports -

-You can import each hook individually import useToggle from 'react-use/lib/useToggle'. -

+```js +import {useToggle} from 'react-use' +``` -

-or use ES6 named imports import {useToggle} from 'react-use'. -

- -

-Depending on your bundler you might run into a missing dependency error with ES6 named import statements. Some hooks require you to install peer dependencies so we recommend using individual imports. If you want the best of both worlds you can transform the named import statements to individual import statements with babel-plugin-import by adding the following config to your `.babelrc` file: -

+Depending on your bundler you might run into a missing dependency error with ES6 named import statements. Some hooks require you to install peer dependencies so we recommend using individual imports. If you want the best of both worlds you can transform the named import statements to individual import statements with [`babel-plugin-import`](https://github.com/ant-design/babel-plugin-import) by adding the following config to your `.babelrc` file: ```json [ @@ -155,13 +145,10 @@ Depending on your bundler you might run into a missing dependency error with ES6 ] ``` -
-

License

Unlicense — public domain.

- [img-demo]: https://img.shields.io/badge/demo-%20%20%20%F0%9F%9A%80-green.svg