You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Usage.md
+8-2Lines changed: 8 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -3,13 +3,19 @@
3
3
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
4
4
5
5
```js
6
-
importuseTogglefrom'react-use/lib/useToggle'
6
+
importuseTogglefrom'react-use/lib/useToggle';
7
7
```
8
8
9
9
or use ES6 named imports (tree shaking recommended)
10
10
11
11
```js
12
-
import {useToggle} from'react-use'
12
+
import { useToggle } from'react-use';
13
+
```
14
+
15
+
For importing types, you should use direct path-based imports
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:
0 commit comments