Skip to content

Commit

Permalink
feat: remove big libs from peerDependencies
Browse files Browse the repository at this point in the history
BREAKING CHANGE: `useSpring` and `useKeyboardJs` hooks need to be imported directly now and libs they depend on are not in peerDependencies anymore.
  • Loading branch information
streamich authored Jul 17, 2019
2 parents 0f137d8 + d3d5bc9 commit 1dbdc5d
Show file tree
Hide file tree
Showing 12 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion docs/Usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ You need to have React [`16.8.0`](https://reactjs.org/blog/2019/02/06/react-v16.
import useToggle from 'react-use/lib/useToggle'
```

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

```js
import {useToggle} from 'react-use'
Expand Down
3 changes: 1 addition & 2 deletions docs/useEvent.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ React sensor hook that subscribes a `handler` to events.
## Usage

```jsx
import useEvent from 'react-use/lib/useEvent';
import useList from 'react-use/lib/useList';
import {useEvent, useList} from 'react-use';

const Demo = () => {
const [list, {push, clear}] = useList();
Expand Down
3 changes: 1 addition & 2 deletions docs/useFullscreen.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ Display an element full-screen, optional fallback for fullscreen video on iOS.
## Usage

```jsx
import useFullscreen from 'react-use/lib/useFullscreen';
import useToggle from 'react-use/lib/useToggle';
import {useFullscreen, useToggle} from 'react-use';

const Demo = () => {
const ref = useRef(null)
Expand Down
2 changes: 1 addition & 1 deletion docs/useInterval.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ React hook that allow you using declarative `setInterval`.

```jsx
import * as React from 'react';
import useInterval from 'react-use/lib/useInterval';
import {useInterval} from 'react-use';

const Demo = () => {
const [count, setCount] = React.useState(0);
Expand Down
2 changes: 1 addition & 1 deletion docs/useKey.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ React UI sensor hook that executes a `handler` when a keyboard key is used.
## Usage

```jsx
import useKey from 'react-use/lib/useKey';
import {useKey} from 'react-use';

const Demo = () => {
const [count, set] = useState(0);
Expand Down
2 changes: 1 addition & 1 deletion docs/useKeyPress.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ key on their keyboard.
## Usage

```jsx
import useKeyPress from 'react-use/lib/useKeyPress';
import {useKeyPress} from 'react-use';

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

Expand Down
2 changes: 1 addition & 1 deletion docs/useKeyPressEvent.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if you press and hold a key, it will fire `keydown` callback only once.

```jsx
import React, { useState } from React;
import useKeyPressEvent from 'react-use/lib/useKeyPressEvent';
import {useKeyPressEvent} from 'react-use';

const Demo = () => {
const [count, setCount] = useState(0);
Expand Down
2 changes: 2 additions & 0 deletions docs/useKeyboardJs.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const Demo = () => {
};
```

Note: Because of dependency on `keyboardjs` you have to import this hook directly like shown above.

## Requirements

Install [`keyboardjs`](https://github.com/RobertWHurst/KeyboardJS) peer dependency:
Expand Down
4 changes: 3 additions & 1 deletion docs/useSpring.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ to spring dynamics.
## Usage

```jsx
import {useSpring} from 'react-use';
import useSpring from 'react-use/lib/useSpring';

const Demo = () => {
const [target, setTarget] = useState(50);
Expand All @@ -23,6 +23,8 @@ const Demo = () => {
};
```

Note: Because of dependency on `rebound` you have to import this hook directly like shown above.

## Requirements

Install [`rebound`](https://github.com/facebook/rebound-js) peer dependency:
Expand Down
2 changes: 1 addition & 1 deletion docs/useStartTyping.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ to focus default input field on the page.
## Usage

```jsx
import useStartTyping from 'react-use/lib/useStartTyping';
import {useStartTyping} from 'react-use';

const Demo = () => {
useStartTyping(() => alert('Started typing...'));
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@
"ts-easing": "^0.2.0"
},
"peerDependencies": {
"keyboardjs": "*",
"react": "^16.8.0",
"react-dom": "^16.8.0",
"rebound": "*"
"react-dom": "^16.8.0"
},
"devDependencies": {
"@babel/core": "7.5.4",
Expand Down
8 changes: 4 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ import useIdle from './useIdle';
import useInterval from './useInterval';
import useIsomorphicLayoutEffect from './useIsomorphicLayoutEffect';
import useKey from './useKey';
import useKeyboardJs from './useKeyboardJs';
// not exported because of peer dependency
// import useKeyboardJs from './useKeyboardJs';
import useKeyPress from './useKeyPress';
import useKeyPressEvent from './useKeyPressEvent';
import useLifecycles from './useLifecycles';
Expand Down Expand Up @@ -60,7 +61,8 @@ import useSessionStorage from './useSessionStorage';
import useSetState from './useSetState';
import useSize from './useSize';
import useSpeech from './useSpeech';
import useSpring from './useSpring';
// not exported because of peer dependency
// import useSpring from './useSpring';
import useStartTyping from './useStartTyping';
import useThrottle from './useThrottle';
import useThrottleFn from './useThrottleFn';
Expand Down Expand Up @@ -107,7 +109,6 @@ export {
useInterval,
useIsomorphicLayoutEffect,
useKey,
useKeyboardJs,
useKeyPress,
useKeyPressEvent,
useLifecycles,
Expand Down Expand Up @@ -139,7 +140,6 @@ export {
useSetState,
useSize,
useSpeech,
useSpring,
useStartTyping,
useThrottle,
useThrottleFn,
Expand Down

0 comments on commit 1dbdc5d

Please sign in to comment.