Skip to content

Commit e3adac0

Browse files
authored
Merge branch 'master' into patch-3
2 parents c7e13bd + fa9d123 commit e3adac0

196 files changed

Lines changed: 5221 additions & 5838 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ version: 2
33
refs:
44
container: &container
55
docker:
6-
- image: node:12.20.1
6+
- image: node:12.21.0
77
working_directory: ~/repo
88
steps:
99
- &Versions

.editorconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ indent_size = 2
88
indent_style = space
99
insert_final_newline = true
1010
trim_trailing_whitespace = true
11-
max_line_length = 120
11+
max_line_length = 100
1212

1313
[*.{ts, tsx}]
1414
ij_typescript_enforce_trailing_comma = keep
@@ -24,8 +24,8 @@ ij_typescript_catch_on_new_line = false
2424
ij_typescript_spaces_within_interpolation_expressions = false
2525

2626
[*.md]
27-
max_line_length = 0
27+
max_line_length = 100
2828
trim_trailing_whitespace = false
2929

3030
[COMMIT_EDITMSG]
31-
max_line_length = 0
31+
max_line_length = 80

.eslintrc.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
module.exports = {
2+
extends: ['prettier/@typescript-eslint', 'react-app', 'plugin:prettier/recommended'],
3+
plugins: ['prettier'],
4+
rules: {
5+
'prettier/prettier': [
6+
'error',
7+
{
8+
singleQuote: true,
9+
trailingComma: 'es5',
10+
tabWidth: 2,
11+
printWidth: 100,
12+
semicolons: true,
13+
quoteProps: 'as-needed',
14+
jsxSingleQuote: false,
15+
bracketSpacing: true,
16+
jsxBracketSameLine: true,
17+
arrowParens: 'always',
18+
endOfLine: 'lf',
19+
},
20+
],
21+
},
22+
};

.eslintrc.json

Lines changed: 0 additions & 3 deletions
This file was deleted.

.prettierrc

Lines changed: 0 additions & 6 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,79 @@
1+
# [17.2.0](https://github.com/streamich/react-use/compare/v17.1.1...v17.2.0) (2021-03-10)
2+
3+
4+
### Bug Fixes
5+
6+
* delete isClient ([72f4cb9](https://github.com/streamich/react-use/commit/72f4cb9b405b3729975bca3acb06658ca467d15b))
7+
* lint issues. ([dc5bbe0](https://github.com/streamich/react-use/commit/dc5bbe0e94d131dda90942ba90c14b200df3f34e))
8+
* **useOrientation:** handle orientation being 0 ([793b053](https://github.com/streamich/react-use/commit/793b0539f0305e2512e7022c45a5c33b842d24d5))
9+
* **useOrientation:** update tests to increase coverage ([f9c743f](https://github.com/streamich/react-use/commit/f9c743fa8375ef726d33f85285d4a5af608f9a42))
10+
* use window inside useEffect ([2f33aa8](https://github.com/streamich/react-use/commit/2f33aa8182c92bf56d49ec3184e6b20f0c0c1e1e))
11+
12+
13+
### Features
14+
15+
* **useOrientation:** add tests ([f45cb70](https://github.com/streamich/react-use/commit/f45cb707b52363f1cb1b32a0ebf2fdbdae79b322))
16+
17+
## [17.1.1](https://github.com/streamich/react-use/compare/v17.1.0...v17.1.1) (2021-02-10)
18+
19+
20+
### Bug Fixes
21+
22+
* useMountedState should not change state on componentDidUpdate lifecycle ([701b306](https://github.com/streamich/react-use/commit/701b306ed97382cbec73c834f6d3dd7baa58e339))
23+
24+
# [17.1.0](https://github.com/streamich/react-use/compare/v17.0.2...v17.1.0) (2021-02-01)
25+
26+
27+
### Features
28+
29+
* **prettier:** make prettier a part of eslint. ([b6993a6](https://github.com/streamich/react-use/commit/b6993a6f95a1b493945c03aecc44dafd10870816))
30+
31+
## [17.0.2](https://github.com/streamich/react-use/compare/v17.0.1...v17.0.2) (2021-02-01)
32+
33+
34+
### Bug Fixes
35+
36+
* proper definition for `useMeasure` ([1461527](https://github.com/streamich/react-use/commit/1461527ffc55b2a1e3c9dc6a0efc2572b66e5381))
37+
38+
## [17.0.1](https://github.com/streamich/react-use/compare/v17.0.0...v17.0.1) (2021-01-31)
39+
40+
41+
### Bug Fixes
42+
43+
* proper definition for isBrowser and isNavigator states. ([a087deb](https://github.com/streamich/react-use/commit/a087deb48e57b1f0a23a2d0a28d0c2d10a640cd6)), closes [#1777](https://github.com/streamich/react-use/issues/1777)
44+
45+
# [17.0.0](https://github.com/streamich/react-use/compare/v16.1.0...v17.0.0) (2021-01-31)
46+
47+
48+
### Features
49+
50+
* refactor the useNetwork hook. ([23037f2](https://github.com/streamich/react-use/commit/23037f207d07604dd2cd7e2cc4ba9475221be780))
51+
52+
53+
### BREAKING CHANGES
54+
55+
* `useNetwork` hook renamed to `useNetworkState`.
56+
57+
# [16.1.0](https://github.com/streamich/react-use/compare/v16.0.0...v16.1.0) (2021-01-31)
58+
59+
60+
### Features
61+
62+
* improve `on` and `off` util functions typing. ([723c588](https://github.com/streamich/react-use/commit/723c588fef6aba9f10ea9f5ea7bc444532519f9a))
63+
64+
# [16.0.0](https://github.com/streamich/react-use/compare/v15.3.8...v16.0.0) (2021-01-30)
65+
66+
67+
### chore
68+
69+
* refactoring and rearrangement. ([a27f09f](https://github.com/streamich/react-use/commit/a27f09fd367f8b172866b5fcbaf66f9a5a3481bb))
70+
71+
72+
### BREAKING CHANGES
73+
74+
* all `create*` factories been moved to `factory` subdirectory and in case direct import should be imported like `react-use/esm/factory/createBreakpoint`
75+
* `comps` directory renamed to `component`
76+
177
## [15.3.8](https://github.com/streamich/react-use/compare/v15.3.7...v15.3.8) (2021-01-08)
278

379

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
<div align="center">
2+
<a href="https://www.kickstarter.com/projects/aleks-p/multiplayer-collaborative-editing-database">
3+
Collaborative editing for your app. <strong>Support on Kickstarter!</strong>
4+
</a>
5+
</div>
6+
7+
18
<div align="center">
29
<h1>
310
<br/>
@@ -58,7 +65,7 @@
5865
- [`useMotion`](./docs/useMotion.md) &mdash; tracks state of device's motion sensor.
5966
- [`useMouse` and `useMouseHovered`](./docs/useMouse.md) &mdash; tracks state of mouse position. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/sensors-usemouse--docs)
6067
- [`useMouseWheel`](./docs/useMouseWheel.md) &mdash; tracks deltaY of scrolled mouse wheel. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/sensors-usemousewheel--docs)
61-
- [`useNetwork`](./docs/useNetwork.md) &mdash; tracks state of user's internet connection.
68+
- [`useNetworkState`](./docs/useNetworkState.md) &mdash; tracks the state of browser's network connection. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/sensors-usenetworkstate--demo)
6269
- [`useOrientation`](./docs/useOrientation.md) &mdash; tracks state of device's screen orientation.
6370
- [`usePageLeave`](./docs/usePageLeave.md) &mdash; triggers when mouse leaves page boundaries.
6471
- [`useScratch`](./docs/useScratch.md) &mdash; tracks mouse click-and-scrub state.

docs/createGlobalState.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# `useGlobalState`
22

3-
A React hook which creates a globally shared state.
3+
A React hook that creates a globally shared state.
44

55
## Usage
66

@@ -30,3 +30,32 @@ const Demo: FC = () => {
3030
);
3131
};
3232
```
33+
34+
It also allows initializing the state with a function and using a function in the setState:
35+
36+
```tsx
37+
const useGlobalValue = createGlobalState<number>(() => 0);
38+
39+
const CompA: FC = () => {
40+
const [value, setValue] = useGlobalValue();
41+
42+
return <button onClick={() => setValue(value => value + 1)}>+</button>;
43+
};
44+
45+
const CompB: FC = () => {
46+
const [value, setValue] = useGlobalValue();
47+
48+
return <button onClick={() => setValue(value => value - 1)}>-</button>;
49+
};
50+
51+
const Demo: FC = () => {
52+
const [value] = useGlobalValue();
53+
return (
54+
<div>
55+
<p>{value}</p>
56+
<CompA />
57+
<CompB />
58+
</div>
59+
);
60+
};
61+
```

docs/useKey.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const Demo = () => {
2323
Or as render-prop:
2424

2525
```jsx
26-
import UseKey from 'react-use/lib/comps/UseKey';
26+
import UseKey from 'react-use/lib/component/UseKey';
2727

2828
<UseKey filter='a' fn={() => alert('"a" key pressed!')} />
2929
```

docs/useMountedState.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# `useMountedState`
22

3+
> **NOTE!:** despite having `State` in its name **_this hook does not cause component re-render_**.
4+
> This component designed to be used to avoid state updates on unmounted components.
5+
36
Lifecycle hook providing ability to check component's mount state.
4-
Gives a function that will return `true` if component mounted and `false` otherwise.
7+
Returns a function that will return `true` if component mounted and `false` otherwise.
58

69
## Usage
710

0 commit comments

Comments
 (0)