Skip to content

Commit 8cade38

Browse files
committed
docs: updated usage instructions for type imports
1 parent ad33f76 commit 8cade38

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

docs/Usage.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ import useToggle from 'react-use/lib/useToggle'
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)