Skip to content

Commit 1dbdc5d

Browse files
authored
feat: remove big libs from peerDependencies
BREAKING CHANGE: `useSpring` and `useKeyboardJs` hooks need to be imported directly now and libs they depend on are not in peerDependencies anymore.
2 parents 0f137d8 + d3d5bc9 commit 1dbdc5d

12 files changed

+18
-18
lines changed

docs/Usage.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ You need to have React [`16.8.0`](https://reactjs.org/blog/2019/02/06/react-v16.
66
import useToggle from 'react-use/lib/useToggle'
77
```
88

9-
or use ES6 named imports
9+
or use ES6 named imports (tree shaking recommended)
1010

1111
```js
1212
import {useToggle} from 'react-use'

docs/useEvent.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ React sensor hook that subscribes a `handler` to events.
66
## Usage
77

88
```jsx
9-
import useEvent from 'react-use/lib/useEvent';
10-
import useList from 'react-use/lib/useList';
9+
import {useEvent, useList} from 'react-use';
1110

1211
const Demo = () => {
1312
const [list, {push, clear}] = useList();

docs/useFullscreen.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@ Display an element full-screen, optional fallback for fullscreen video on iOS.
55
## Usage
66

77
```jsx
8-
import useFullscreen from 'react-use/lib/useFullscreen';
9-
import useToggle from 'react-use/lib/useToggle';
8+
import {useFullscreen, useToggle} from 'react-use';
109

1110
const Demo = () => {
1211
const ref = useRef(null)

docs/useInterval.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ React hook that allow you using declarative `setInterval`.
66

77
```jsx
88
import * as React from 'react';
9-
import useInterval from 'react-use/lib/useInterval';
9+
import {useInterval} from 'react-use';
1010

1111
const Demo = () => {
1212
const [count, setCount] = React.useState(0);

docs/useKey.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ React UI sensor hook that executes a `handler` when a keyboard key is used.
55
## Usage
66

77
```jsx
8-
import useKey from 'react-use/lib/useKey';
8+
import {useKey} from 'react-use';
99

1010
const Demo = () => {
1111
const [count, set] = useState(0);

docs/useKeyPress.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ key on their keyboard.
77
## Usage
88

99
```jsx
10-
import useKeyPress from 'react-use/lib/useKeyPress';
10+
import {useKeyPress} from 'react-use';
1111

1212
const keys = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'];
1313

docs/useKeyPressEvent.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ if you press and hold a key, it will fire `keydown` callback only once.
99

1010
```jsx
1111
import React, { useState } from React;
12-
import useKeyPressEvent from 'react-use/lib/useKeyPressEvent';
12+
import {useKeyPressEvent} from 'react-use';
1313

1414
const Demo = () => {
1515
const [count, setCount] = useState(0);

docs/useKeyboardJs.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ const Demo = () => {
2222
};
2323
```
2424

25+
Note: Because of dependency on `keyboardjs` you have to import this hook directly like shown above.
26+
2527
## Requirements
2628

2729
Install [`keyboardjs`](https://github.com/RobertWHurst/KeyboardJS) peer dependency:

docs/useSpring.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ to spring dynamics.
66
## Usage
77

88
```jsx
9-
import {useSpring} from 'react-use';
9+
import useSpring from 'react-use/lib/useSpring';
1010

1111
const Demo = () => {
1212
const [target, setTarget] = useState(50);
@@ -23,6 +23,8 @@ const Demo = () => {
2323
};
2424
```
2525

26+
Note: Because of dependency on `rebound` you have to import this hook directly like shown above.
27+
2628
## Requirements
2729

2830
Install [`rebound`](https://github.com/facebook/rebound-js) peer dependency:

docs/useStartTyping.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ to focus default input field on the page.
66
## Usage
77

88
```jsx
9-
import useStartTyping from 'react-use/lib/useStartTyping';
9+
import {useStartTyping} from 'react-use';
1010

1111
const Demo = () => {
1212
useStartTyping(() => alert('Started typing...'));

package.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,8 @@
5555
"ts-easing": "^0.2.0"
5656
},
5757
"peerDependencies": {
58-
"keyboardjs": "*",
5958
"react": "^16.8.0",
60-
"react-dom": "^16.8.0",
61-
"rebound": "*"
59+
"react-dom": "^16.8.0"
6260
},
6361
"devDependencies": {
6462
"@babel/core": "7.5.4",

src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ import useIdle from './useIdle';
2828
import useInterval from './useInterval';
2929
import useIsomorphicLayoutEffect from './useIsomorphicLayoutEffect';
3030
import useKey from './useKey';
31-
import useKeyboardJs from './useKeyboardJs';
31+
// not exported because of peer dependency
32+
// import useKeyboardJs from './useKeyboardJs';
3233
import useKeyPress from './useKeyPress';
3334
import useKeyPressEvent from './useKeyPressEvent';
3435
import useLifecycles from './useLifecycles';
@@ -60,7 +61,8 @@ import useSessionStorage from './useSessionStorage';
6061
import useSetState from './useSetState';
6162
import useSize from './useSize';
6263
import useSpeech from './useSpeech';
63-
import useSpring from './useSpring';
64+
// not exported because of peer dependency
65+
// import useSpring from './useSpring';
6466
import useStartTyping from './useStartTyping';
6567
import useThrottle from './useThrottle';
6668
import useThrottleFn from './useThrottleFn';
@@ -107,7 +109,6 @@ export {
107109
useInterval,
108110
useIsomorphicLayoutEffect,
109111
useKey,
110-
useKeyboardJs,
111112
useKeyPress,
112113
useKeyPressEvent,
113114
useLifecycles,
@@ -139,7 +140,6 @@ export {
139140
useSetState,
140141
useSize,
141142
useSpeech,
142-
useSpring,
143143
useStartTyping,
144144
useThrottle,
145145
useThrottleFn,

0 commit comments

Comments
 (0)