Skip to content

Commit 4172dfb

Browse files
committed
docs: updated usage instructions for type imports
1 parent ad33f76 commit 4172dfb

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

docs/Usage.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,19 @@
33
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
44

55
```js
6-
import useToggle from 'react-use/lib/useToggle'
6+
import useToggle from 'react-use/lib/useToggle';
77
```
88

99
or use ES6 named imports (tree shaking recommended)
1010

1111
```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
16+
17+
```js
18+
import GeoLocationSensorState from 'react-use/lib/useGeolocation';
1319
```
1420

1521
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

Comments
 (0)