diff --git a/.circleci/config.yml b/.circleci/config.yml
deleted file mode 100644
index 80ae1029dd..0000000000
--- a/.circleci/config.yml
+++ /dev/null
@@ -1,97 +0,0 @@
-version: 2
-
-refs:
- container: &container
- docker:
- - image: node:8.11
- working_directory: ~/repo
- steps:
- - &Versions
- run:
- name: Versions
- command: node -v && npm -v && yarn -v
- - &Install
- run:
- name: Install Dependencies
- command: yarn install --pure-lockfile
- - &Build
- run:
- name: Build
- command: yarn build
- - &Build_Storybook
- run:
- name: Build Storybook
- command: yarn storybook:build
- - &Test
- run:
- name: Test
- command: yarn test
- - &Upload_Storybook
- run:
- name: Upload Storybook
- command: yarn storybook:upload
- - &Release
- run:
- name: Release
- command: yarn release
- - &Commit_Status_Storybook
- run:
- name: Post commit status for Storybook
- command: |
- npx cross-ci :run \
- npx commit-status success Storybook "'\${BUILD_VERSION}'" "'https://$CIRCLE_BUILD_NUM-154950925-gh.circle-artifacts.com/0/root/repo/storybook-static/index.html'"
-
-jobs:
- all:
- <<: *container
- steps:
- - checkout
- - *Versions
- - *Install
- - *Build
- - *Build_Storybook
- - *Test
- - store_artifacts:
- path: ~/repo/storybook-static
- - *Commit_Status_Storybook
-
- master:
- <<: *container
- steps:
- - checkout
- - *Versions
- - *Install
- - *Build
- - *Build_Storybook
- - *Test
- - store_artifacts:
- path: ~/repo/storybook-static
- - *Commit_Status_Storybook
- - run:
- name: Setup GitHub
- command: |
- git config --global user.email "streamich@gmail.com"
- git config --global user.name "streamich"
- git remote rm origin
- git remote add origin https://${GITHUB_TOKEN}@github.com/streamich/react-use
- - *Upload_Storybook
- - *Release
-
-workflows:
- version: 2
- all:
- jobs:
- - all:
- context: common-env-vars
- filters:
- branches:
- ignore:
- - master
- - gh-pages
- master:
- jobs:
- - master:
- context: common-env-vars
- filters:
- branches:
- only: master
diff --git a/.editorconfig b/.editorconfig
index d7638731d0..92b7b4bec2 100644
--- a/.editorconfig
+++ b/.editorconfig
@@ -7,12 +7,25 @@ end_of_line = lf
indent_size = 2
indent_style = space
insert_final_newline = true
-max_line_length = 80
trim_trailing_whitespace = true
+max_line_length = 100
+
+[*.{ts, tsx}]
+ij_typescript_enforce_trailing_comma = keep
+ij_typescript_use_double_quotes = false
+ij_typescript_force_quote_style = true
+ij_typescript_align_imports = false
+ij_typescript_align_multiline_ternary_operation = false
+ij_typescript_align_multiline_parameters_in_calls = false
+ij_typescript_align_multiline_parameters = false
+ij_typescript_align_multiline_chained_methods = false
+ij_typescript_else_on_new_line = false
+ij_typescript_catch_on_new_line = false
+ij_typescript_spaces_within_interpolation_expressions = false
[*.md]
-max_line_length = 0
+max_line_length = 100
trim_trailing_whitespace = false
[COMMIT_EDITMSG]
-max_line_length = 0
+max_line_length = 80
diff --git a/.eslintrc.js b/.eslintrc.js
new file mode 100644
index 0000000000..58d020238b
--- /dev/null
+++ b/.eslintrc.js
@@ -0,0 +1,22 @@
+module.exports = {
+ extends: ['react-app', 'prettier'],
+ plugins: ['prettier'],
+ rules: {
+ 'prettier/prettier': [
+ 'error',
+ {
+ singleQuote: true,
+ trailingComma: 'es5',
+ tabWidth: 2,
+ printWidth: 100,
+ semicolons: true,
+ quoteProps: 'as-needed',
+ jsxSingleQuote: false,
+ bracketSpacing: true,
+ jsxBracketSameLine: true,
+ arrowParens: 'always',
+ endOfLine: 'lf',
+ },
+ ],
+ },
+};
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
new file mode 100644
index 0000000000..dbfac2729f
--- /dev/null
+++ b/.github/FUNDING.yml
@@ -0,0 +1,100 @@
+# These are supported funding model platforms
+
+github: [
+ "streamich",
+ "wardoost",
+ "xobotyi",
+ "Belco90",
+ "ankithkonda",
+ "ayush987goyal",
+ "NullVoxPopuli",
+ "lintuming",
+ "Granipouss",
+ "ythecombinator",
+ "james2406",
+ "jakapatb",
+ "MrHuangJser",
+ "zaguiini",
+ "ppeeou",
+ "liuyuchenzh",
+ "brickspert",
+ "artywhite",
+ "PetterIve",
+ "realdennis",
+ "lvl99",
+ "gelove",
+ "KusStar",
+ "xiaoxiangmoe",
+ "nmccready",
+ "mattleonowicz",
+ "kevinnorris",
+ "dubzzz",
+ "dependabot[bot]",
+ "ShizukuIchi",
+ "ManojBahuguna",
+ "Jivings",
+ "Dosant",
+ "zsh2401",
+ "xiaoboost",
+ "revskill10",
+ "mtinner",
+ "monkeywithacupcake",
+ "mitchheddles",
+ "maxzitron",
+ "macinjoke",
+ "jeetiss",
+ "ilyalesik",
+ "hijiangtao",
+ "f",
+ "elliottsj",
+ "droganov",
+ "denysdovhan",
+ "dabuside",
+ "benneq",
+ "azukaar",
+ "ariesjia",
+ "andrico1234",
+ "adesurirey",
+ "OBe95",
+ "FredyC",
+ "Cretezy",
+ "zyy7259",
+ "zslabs",
+ "vinitsood",
+ "uxitten",
+ "thevtm",
+ "tanem",
+ "suyingtao",
+ "srph",
+ "rkostrzewski",
+ "qianL93",
+ "o-alexandrov",
+ "nucleartux",
+ "natew",
+ "maxmalov",
+ "liaoyinglong",
+ "koenvanzuijlen",
+ "josmardias",
+ "jeemyeong",
+ "jazzqi",
+ "jakyle",
+ "jakeboone02",
+ "inker",
+ "glarivie",
+ "garrettmaring",
+ "dovidweisz",
+ "daniel-hauser",
+ "d-asensio",
+ "charlax",
+ "TylerR909",
+ "Rogdham",
+ "OctoD",
+ "MajorBreakfast",
+ "Jfelix61",
+ "Flydiverny",
+ "FlickerLogicalStack",
+ "DmacMcgreg",
+ "Dattaya",
+ "Andrey-Bazhanov",
+ "AlvaroBernalG"
+]
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
new file mode 100644
index 0000000000..9ac7935abf
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,21 @@
+---
+name: Bug report
+about: Create a report if you having any problems using the package
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+**What is the current behavior?**
+
+**Steps to reproduce it and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have extra dependencies other than `react-use`. Paste the link to your [JSFiddle](https://jsfiddle.net) or [CodeSandbox](https://codesandbox.io) example below:**
+
+**What is the expected behavior?**
+
+**A little about versions:**
+- _OS_:
+- _Browser (vendor and version)_:
+- _React_:
+- _`react-use`_:
+- _Did this worked in the previous package version?_
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
new file mode 100644
index 0000000000..e2eb756b9a
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,17 @@
+---
+name: Feature request
+about: Have an idea? Great! Let us know, maybe we`ve been waiting only for you =)
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+**Is your feature request related to a problem? Please describe.**
+A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
+
+**Describe the solution you'd like**
+A clear and concise description of what you want to happen.
+
+**Describe alternatives you've considered**
+A clear and concise description of any alternative solutions or features you've considered.
diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 0000000000..bfcd240e6f
--- /dev/null
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,25 @@
+# Description
+
+
+
+
+## Type of change
+
+
+- [ ] Bug fix _(non-breaking change which fixes an issue)_
+- [ ] New feature _(non-breaking change which adds functionality)_
+- [ ] **Breaking change** _(fix or feature that would cause existing functionality to not work as before)_
+
+# Checklist
+- [ ] Read the [Contributing Guide](https://github.com/streamich/react-use/blob/master/CONTRIBUTING.md)
+- [ ] Perform a code self-review
+- [ ] Comment the code, particularly in hard-to-understand areas
+- [ ] Add documentation
+- [ ] Add hook's story at Storybook
+- [ ] Cover changes with tests
+- [ ] Ensure the test suite passes (`yarn test`)
+- [ ] Provide 100% tests coverage
+- [ ] Make sure code lints (`yarn lint`). Fix it with `yarn lint:fix` in case of failure.
+- [ ] Make sure types are fine (`yarn lint:types`).
+
+
diff --git a/.github/workflows/check-codebase.yml b/.github/workflows/check-codebase.yml
new file mode 100644
index 0000000000..be17d2e23d
--- /dev/null
+++ b/.github/workflows/check-codebase.yml
@@ -0,0 +1,90 @@
+name: Check codebase
+
+on:
+ push:
+ branches:
+ - master
+ pull_request:
+ branches:
+ - master
+
+jobs:
+ build:
+ name: Build
+ runs-on: ubuntu-latest
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@v2
+
+ - name: Setup node
+ uses: actions/setup-node@v1
+ with:
+ node-version: 20
+
+ - name: Install dependencies
+ run: yarn install --frozen-lockfile
+
+ - name: Run build
+ run: yarn build
+
+ # storybook:
+ # name: Storybook
+ # runs-on: ubuntu-latest
+ # steps:
+ # - name: Check out repository
+ # uses: actions/checkout@v2
+
+ # - name: Setup node
+ # uses: actions/setup-node@v1
+ # with:
+ # node-version: 20
+
+ # - name: Install dependencies
+ # run: yarn install --frozen-lockfile
+
+ # - name: Run build:storybook
+ # run: yarn storybook:build
+
+ lint:
+ name: Linting
+ runs-on: ubuntu-latest
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@v2
+
+ - name: Setup node
+ uses: actions/setup-node@v1
+ with:
+ node-version: 20
+
+ - name: Install dependencies
+ run: yarn install --frozen-lockfile
+
+ - name: Lint with ESLint
+ run: yarn lint
+
+ - name: Lint with TSC
+ if: ${{ always() }}
+ run: yarn lint:types
+
+ unit-tests:
+ name: Unit tests
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ os: [macos-latest, ubuntu-latest]
+ node: [20, 22]
+ steps:
+ - name: Check out repository
+ uses: actions/checkout@v2
+
+ - name: Setup node
+ uses: actions/setup-node@v1
+ with:
+ node-version: ${{ matrix.node }}
+
+ - name: Install dependencies
+ run: yarn install --frozen-lockfile
+
+ - name: Run unit tests
+ run: yarn test
diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml
new file mode 100644
index 0000000000..f732451311
--- /dev/null
+++ b/.github/workflows/mirror.yml
@@ -0,0 +1,21 @@
+name: Node.js CI
+
+on:
+ push:
+ branches: [master]
+
+jobs:
+ mirror:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ - name: Push To Gitlab
+ env:
+ token: ${{ secrets.GITLAB_TOKEN }}
+ run: |
+ git config user.name "streamich"
+ git config user.email "react-use+streamich@users.noreply.github.com"
+ git remote add mirror "https://oauth2:${token}@gitlab.com/streamich/react-use.git"
+ git push mirror master
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
new file mode 100644
index 0000000000..81ed2cc471
--- /dev/null
+++ b/.github/workflows/release.yml
@@ -0,0 +1,30 @@
+name: Node.js CI
+
+on:
+ push:
+ branches: [master, next]
+
+jobs:
+ release:
+ if: ${{ github.event_name == 'push' && (github.event.ref == 'refs/heads/master' || github.event.ref == 'refs/heads/next') }}
+ runs-on: ubuntu-latest
+ strategy:
+ matrix:
+ node-version: [22.x]
+ steps:
+ - uses: actions/checkout@v4
+ - name: Use Node.js ${{ matrix.node-version }}
+ uses: actions/setup-node@v4
+ with:
+ node-version: ${{ matrix.node-version }}
+ cache: yarn
+ - run: yarn install --frozen-lockfile
+ - run: yarn lint
+ - run: yarn test
+ - run: yarn lint:types
+ - run: yarn build
+ - name: Semantic Release
+ uses: cycjimmy/semantic-release-action@v4
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
diff --git a/.gitignore b/.gitignore
index 3d818536e4..95c09a18a6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,6 +11,10 @@ pids
*.seed
*.pid.lock
+# IDE files
+.idea
+.vscode
+
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
@@ -62,6 +66,7 @@ typings/
# build output
lib/
+esm
.DS_Store
@@ -71,3 +76,4 @@ src/parser.ts
.puppet-master/
storybook-static/
+package-lock.json
diff --git a/.storybook/addons.js b/.storybook/addons.js
index e69de29bb2..1d7ca1fc50 100644
--- a/.storybook/addons.js
+++ b/.storybook/addons.js
@@ -0,0 +1,4 @@
+import '@storybook/addon-knobs/register';
+import '@storybook/addon-options/register';
+import '@storybook/addon-actions/register';
+import '@storybook/addon-notes/register';
diff --git a/.storybook/config.js b/.storybook/config.js
index 8f54bc138e..93dcc97cfc 100644
--- a/.storybook/config.js
+++ b/.storybook/config.js
@@ -1,6 +1,18 @@
import {configure} from '@storybook/react';
+import {setOptions} from '@storybook/addon-options';
-const req = require.context('../src/__stories__/', true, /.*\.(stories|story)\.(js|jsx|ts|tsx)?$/);
+setOptions({
+ sortStoriesByKind: false,
+ showStoriesPanel: true,
+ showAddonPanel: true,
+ showSearchBox: false,
+ addonPanelInRight: true,
+ hierarchySeparator: /\//,
+ hierarchyRootSeparator: /\|/,
+ sidebarAnimations: false,
+});
+
+const req = require.context('../stories/', true, /\.story\.tsx?$/);
const loadStories = () => {
req.keys().forEach((filename) => req(filename));
diff --git a/.storybook/webpack.config.js b/.storybook/webpack.config.js
index 3dd9a77b71..5771154606 100644
--- a/.storybook/webpack.config.js
+++ b/.storybook/webpack.config.js
@@ -1,22 +1,39 @@
const path = require('path');
+const { compilerOptions } = require('../tsconfig.json');
+const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
-const SRC_PATH = path.join(__dirname, '../src');
+const basedir = path.join(__dirname, '..');
-module.exports = {
- module: {
- rules: [
- {
- test: /\.tsx?$/,
- loader: 'ts-loader',
- include: [
- SRC_PATH,
- ]
- }
- ]
- },
+module.exports = async ({ config, mode }) => {
+ config.module.rules.push(
+ {
+ test: /\.md?$/,
+ loader: "markdown-loader",
+ },
+ {
+ test: /\.tsx?$/,
+ loader: 'ts-loader',
+ include: [
+ path.join(basedir, 'src'),
+ path.join(basedir, 'stories'),
+ ],
+ options: {
+ transpileOnly: true, // use transpileOnly mode to speed-up compilation
+ compilerOptions: {
+ ...compilerOptions,
+ declaration: false,
+ },
+ },
+ },
+ );
- resolve: {
- extensions: ['.ts', '.tsx', '.js', '.jsx'],
- enforceExtension: false
- }
+ config.plugins.push(new ForkTsCheckerWebpackPlugin());
+
+ config.resolve.extensions = ['.ts', '.tsx', '.js', '.jsx'];
+ config.resolve.enforceExtension = false;
+
+ // disable the hint about too big bundle
+ config.performance.hints = false;
+
+ return config;
};
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000000..33377a026a
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,25 @@
+language: node_js
+os:
+ - linux
+cache:
+ yarn: true
+ directories:
+ - ~/.npm
+notifications:
+ email: false
+node_js:
+ - '10'
+script:
+ - yarn lint
+ - yarn test
+ - yarn build
+ - yarn storybook:build
+matrix:
+ allow_failures: []
+ fast_finish: true
+branches:
+ except:
+ - /^v\d+\.\d+\.\d+$/
+ - master
+ - next
+ - gh-pages
diff --git a/CHANGELOG.md b/CHANGELOG.md
index c068ca6995..2b3362796e 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,1899 @@
+# [17.6.0](https://github.com/streamich/react-use/compare/v17.5.1...v17.6.0) (2024-12-09)
+
+
+### Features
+
+* add onChange callback to useWindowSize ([ea656f7](https://github.com/streamich/react-use/commit/ea656f7e751b8366360ce2aa8238057bbbc1251a))
+* add onChange callback to useWindowSize ([3eb531a](https://github.com/streamich/react-use/commit/3eb531ac9e9e04641df29aafbd2677869cdcb085))
+
+## [17.5.1](https://github.com/streamich/react-use/compare/v17.5.0...v17.5.1) (2024-07-20)
+
+
+### Bug Fixes
+
+* 🐛 bump nano-css dependency ([adfb337](https://github.com/streamich/react-use/commit/adfb337d5b11427798afc5a21c6ebdaa76212182))
+
+# [17.5.0](https://github.com/streamich/react-use/compare/v17.4.4...v17.5.0) (2024-01-22)
+
+
+### Features
+
+* add `isFirst` and `isLast` methods to `useStateList` hook ([ac64414](https://github.com/streamich/react-use/commit/ac64414bea4c8afadfb382da9fea44ee89b41e2d))
+* **pencil:** add isFirst and isLast return value to 'useStateList' ([75218e4](https://github.com/streamich/react-use/commit/75218e45dfdcdc6ea193e278cb97ceee98c00f1b))
+* **pencil:** fix with yarn lint:fix ([6a9dde5](https://github.com/streamich/react-use/commit/6a9dde596ae25c0dd2fa97b0cf354143fbc5b5ff))
+
+## [17.4.4](https://github.com/streamich/react-use/compare/v17.4.3...v17.4.4) (2024-01-21)
+
+
+### Bug Fixes
+
+* typo in example ([0534648](https://github.com/streamich/react-use/commit/05346481a15a321b13838eead0bda3024b0d163f))
+
+## [17.4.3](https://github.com/streamich/react-use/compare/v17.4.2...v17.4.3) (2024-01-13)
+
+
+### Bug Fixes
+
+* update useMedia hook to use recommended approach of MDN ([e7379f0](https://github.com/streamich/react-use/commit/e7379f088787cbf9274c1fc21d36061f04855e4c))
+
+## [17.4.2](https://github.com/streamich/react-use/compare/v17.4.1...v17.4.2) (2023-12-01)
+
+
+### Bug Fixes
+
+* correct peer dependencies ([d770587](https://github.com/streamich/react-use/commit/d77058729654397b68b251e8211bf0edc0b4ed50))
+
+## [17.4.1](https://github.com/streamich/react-use/compare/v17.4.0...v17.4.1) (2023-11-28)
+
+
+### Bug Fixes
+
+* 🐛 bump nano-css version ([812952b](https://github.com/streamich/react-use/commit/812952bb9ff004a844ec4285ad6c65d39597b11c))
+
+# [17.4.0](https://github.com/streamich/react-use/compare/v17.3.3...v17.4.0) (2022-05-20)
+
+
+### Features
+
+* add usePinchZoom sensor hook ([3e042cb](https://github.com/streamich/react-use/commit/3e042cb2f3022349a53199b5cc5c380e3ebd9975))
+
+## [17.3.3](https://github.com/streamich/react-use/compare/v17.3.2...v17.3.3) (2022-05-20)
+
+
+### Bug Fixes
+
+* bump React peer dependency version ([532e865](https://github.com/streamich/react-use/commit/532e8653a50d39dd439d9664d4813a1d7a5b4f3c))
+* resolve [#2319](https://github.com/streamich/react-use/issues/2319) ([4884b2c](https://github.com/streamich/react-use/commit/4884b2c74085e0841af7c36cca34e16d698d1b4c))
+* resolve @types/react@18 break change, React.FC ([20b7817](https://github.com/streamich/react-use/commit/20b78178d0033cc2e0c2a904e413b20ee864c816))
+
+## [17.3.2](https://github.com/streamich/react-use/compare/v17.3.1...v17.3.2) (2021-12-30)
+
+
+### Bug Fixes
+
+* useMedia SSR hydration bug with defaultState ([#2216](https://github.com/streamich/react-use/issues/2216)) ([5c01189](https://github.com/streamich/react-use/commit/5c0118941280bb265ca7813afb987f89c8c97a17))
+
+## [17.3.1](https://github.com/streamich/react-use/compare/v17.3.0...v17.3.1) (2021-08-31)
+
+
+### Performance Improvements
+
+* ⚡️ change title only if it changed ([51ef8d9](https://github.com/streamich/react-use/commit/51ef8d99bad31186ec5420d8b729748507c8a1bf))
+
+# [17.3.0](https://github.com/streamich/react-use/compare/v17.2.4...v17.3.0) (2021-08-31)
+
+
+### Bug Fixes
+
+* do not re-render unncessarily in useAsyncFn hook ([fa3ba25](https://github.com/streamich/react-use/commit/fa3ba2520ede6866b599f6df55fdfa6395058cd2))
+
+
+### Features
+
+* useAudio add playing state ([3203610](https://github.com/streamich/react-use/commit/3203610efdcb8e1fe3c6a17ea19e41bacbeb851b))
+
+## [17.2.4](https://github.com/streamich/react-use/compare/v17.2.3...v17.2.4) (2021-04-23)
+
+
+### Bug Fixes
+
+* lint issues. ([66b0f23](https://github.com/streamich/react-use/commit/66b0f235477c5f93807df75a53a84b3c5cd053e5))
+* **useLocalStorage:** reinitialize on key change ([fdd1b23](https://github.com/streamich/react-use/commit/fdd1b23fd7ba6ae30139eeef02c552a8c7d6d333))
+* add generic typing to createHTMLMediaHook. no typecheck problem with ref anymore. ([1f547ef](https://github.com/streamich/react-use/commit/1f547efb12d6cbe7687e86925ad80bd85fac3dfd))
+* add generic typing to createHTMLMediaHook. no typecheck problem with ref anymore. ([ac4dd78](https://github.com/streamich/react-use/commit/ac4dd786f42a2c59bdaaf9ddebe2e830982d7fcc))
+
+## [17.2.3](https://github.com/streamich/react-use/compare/v17.2.2...v17.2.3) (2021-04-06)
+
+
+### Bug Fixes
+
+* lint issues. ([5a5a575](https://github.com/streamich/react-use/commit/5a5a5755bc1f10add9c7a100ea6577ab6d427c0c))
+
+## [17.2.2](https://github.com/streamich/react-use/compare/v17.2.1...v17.2.2) (2021-04-06)
+
+
+### Bug Fixes
+
+* **useStateWithHistory:** support callback style setState ([fca687d](https://github.com/streamich/react-use/commit/fca687d32c37148dab3072f053109f6c4d3c36ba))
+
+## [17.2.1](https://github.com/streamich/react-use/compare/v17.2.0...v17.2.1) (2021-03-11)
+
+
+### Bug Fixes
+
+* lint issues. ([3e8af15](https://github.com/streamich/react-use/commit/3e8af15086135c873d18079a0b92b21da668a2ff))
+* useMeasure type definitions for SVG ([e200f7f](https://github.com/streamich/react-use/commit/e200f7fcbb371a1d794be8d350f9559f940e5760))
+* useUnmountPromise stops on immediate update ([9ff5c09](https://github.com/streamich/react-use/commit/9ff5c09e671c4f07f25f30a60617fca7660e7607))
+
+# [17.2.0](https://github.com/streamich/react-use/compare/v17.1.1...v17.2.0) (2021-03-10)
+
+
+### Bug Fixes
+
+* delete isClient ([72f4cb9](https://github.com/streamich/react-use/commit/72f4cb9b405b3729975bca3acb06658ca467d15b))
+* lint issues. ([dc5bbe0](https://github.com/streamich/react-use/commit/dc5bbe0e94d131dda90942ba90c14b200df3f34e))
+* **useOrientation:** handle orientation being 0 ([793b053](https://github.com/streamich/react-use/commit/793b0539f0305e2512e7022c45a5c33b842d24d5))
+* **useOrientation:** update tests to increase coverage ([f9c743f](https://github.com/streamich/react-use/commit/f9c743fa8375ef726d33f85285d4a5af608f9a42))
+* use window inside useEffect ([2f33aa8](https://github.com/streamich/react-use/commit/2f33aa8182c92bf56d49ec3184e6b20f0c0c1e1e))
+
+
+### Features
+
+* **useOrientation:** add tests ([f45cb70](https://github.com/streamich/react-use/commit/f45cb707b52363f1cb1b32a0ebf2fdbdae79b322))
+
+## [17.1.1](https://github.com/streamich/react-use/compare/v17.1.0...v17.1.1) (2021-02-10)
+
+
+### Bug Fixes
+
+* useMountedState should not change state on componentDidUpdate lifecycle ([701b306](https://github.com/streamich/react-use/commit/701b306ed97382cbec73c834f6d3dd7baa58e339))
+
+# [17.1.0](https://github.com/streamich/react-use/compare/v17.0.2...v17.1.0) (2021-02-01)
+
+
+### Features
+
+* **prettier:** make prettier a part of eslint. ([b6993a6](https://github.com/streamich/react-use/commit/b6993a6f95a1b493945c03aecc44dafd10870816))
+
+## [17.0.2](https://github.com/streamich/react-use/compare/v17.0.1...v17.0.2) (2021-02-01)
+
+
+### Bug Fixes
+
+* proper definition for `useMeasure` ([1461527](https://github.com/streamich/react-use/commit/1461527ffc55b2a1e3c9dc6a0efc2572b66e5381))
+
+## [17.0.1](https://github.com/streamich/react-use/compare/v17.0.0...v17.0.1) (2021-01-31)
+
+
+### Bug Fixes
+
+* 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)
+
+# [17.0.0](https://github.com/streamich/react-use/compare/v16.1.0...v17.0.0) (2021-01-31)
+
+
+### Features
+
+* refactor the useNetwork hook. ([23037f2](https://github.com/streamich/react-use/commit/23037f207d07604dd2cd7e2cc4ba9475221be780))
+
+
+### BREAKING CHANGES
+
+* `useNetwork` hook renamed to `useNetworkState`.
+
+# [16.1.0](https://github.com/streamich/react-use/compare/v16.0.0...v16.1.0) (2021-01-31)
+
+
+### Features
+
+* improve `on` and `off` util functions typing. ([723c588](https://github.com/streamich/react-use/commit/723c588fef6aba9f10ea9f5ea7bc444532519f9a))
+
+# [16.0.0](https://github.com/streamich/react-use/compare/v15.3.8...v16.0.0) (2021-01-30)
+
+
+### chore
+
+* refactoring and rearrangement. ([a27f09f](https://github.com/streamich/react-use/commit/a27f09fd367f8b172866b5fcbaf66f9a5a3481bb))
+
+
+### BREAKING CHANGES
+
+* all `create*` factories been moved to `factory` subdirectory and in case direct import should be imported like `react-use/esm/factory/createBreakpoint`
+* `comps` directory renamed to `component`
+
+## [15.3.8](https://github.com/streamich/react-use/compare/v15.3.7...v15.3.8) (2021-01-08)
+
+
+### Bug Fixes
+
+* improve useStateValidator and useMultiStateValidator typings. ([acff81d](https://github.com/streamich/react-use/commit/acff81d99abdbbefcc2985297ee01c3cda9ef4c9))
+
+## [15.3.7](https://github.com/streamich/react-use/compare/v15.3.6...v15.3.7) (2021-01-08)
+
+
+### Bug Fixes
+
+* [#1646](https://github.com/streamich/react-use/issues/1646) ([ebc7094](https://github.com/streamich/react-use/commit/ebc7094bbc156be57b3de855c6984c1d056cf0e6))
+
+## [15.3.6](https://github.com/streamich/react-use/compare/v15.3.5...v15.3.6) (2021-01-07)
+
+
+### Bug Fixes
+
+* Fix issues in tests ([7668ce5](https://github.com/streamich/react-use/commit/7668ce5c5f0f186437907f1c352d3a62e3ae8ba7))
+
+## [15.3.4](https://github.com/streamich/react-use/compare/v15.3.3...v15.3.4) (2020-09-04)
+
+
+### Bug Fixes
+
+* useLongPress hook linting fixes. ([479dd99](https://github.com/streamich/react-use/commit/479dd9977bfcc43ccadc58eb93690adee462a16e))
+
+## [15.3.3](https://github.com/streamich/react-use/compare/v15.3.2...v15.3.3) (2020-07-24)
+
+
+### Bug Fixes
+
+* replace createFactory usages with createElement ([ad29bea](https://github.com/streamich/react-use/commit/ad29bea7b03f46aa697e6623bdf7a17347ace651))
+
+## [15.3.2](https://github.com/streamich/react-use/compare/v15.3.1...v15.3.2) (2020-06-29)
+
+
+### Bug Fixes
+
+* **useFullscreen:** fix typings so [#1205](https://github.com/streamich/react-use/issues/1205) can be merged. ([e6e55a3](https://github.com/streamich/react-use/commit/e6e55a3f94993b621566ac66488fd973e992704f))
+
+## [15.3.1](https://github.com/streamich/react-use/compare/v15.3.0...v15.3.1) (2020-06-29)
+
+
+### Bug Fixes
+
+* **usePrevious:** revert the reworked variant as a fix of [#1315](https://github.com/streamich/react-use/issues/1315) ([a4279eb](https://github.com/streamich/react-use/commit/a4279eb660f6b433ed88e0d90c2bb0b3158d3b00))
+
+# [15.3.0](https://github.com/streamich/react-use/compare/v15.2.5...v15.3.0) (2020-06-19)
+
+
+### Features
+
+* **usePrevious:** reworked the hook, now it is more memory-efficient. ([8c6f467](https://github.com/streamich/react-use/commit/8c6f4675beac9c71e96126dd6f06f455c4e4bf01))
+
+## [15.2.5](https://github.com/streamich/react-use/compare/v15.2.4...v15.2.5) (2020-06-15)
+
+
+### Bug Fixes
+
+* bump react-universal-interface ([1540c1a](https://github.com/streamich/react-use/commit/1540c1ab8f338dfa2f53de16506fbf47803d45ba))
+
+## [15.2.4](https://github.com/streamich/react-use/compare/v15.2.3...v15.2.4) (2020-06-13)
+
+
+### Bug Fixes
+
+* doesn't unlock the body on unmount ([1ead4ef](https://github.com/streamich/react-use/commit/1ead4efab6c67131e480570b578b0ce803204953))
+
+## [15.2.3](https://github.com/streamich/react-use/compare/v15.2.2...v15.2.3) (2020-06-13)
+
+
+### Bug Fixes
+
+* 🐛 improve how text is dropped in useDrop hook ([b2f46d1](https://github.com/streamich/react-use/commit/b2f46d10f25c5e658bb7f790950a1fd9a4e5e288))
+
+## [15.2.2](https://github.com/streamich/react-use/compare/v15.2.1...v15.2.2) (2020-06-08)
+
+
+### Bug Fixes
+
+* repair useKeyboardJs hook ([8410bb0](https://github.com/streamich/react-use/commit/8410bb042fec8f1996e8bcecb85fadfbb414b3f9))
+
+## [15.2.1](https://github.com/streamich/react-use/compare/v15.2.0...v15.2.1) (2020-06-08)
+
+
+### Bug Fixes
+
+* 🐛 bump fast-deep-equal, and consume it through ES import ([f3c715c](https://github.com/streamich/react-use/commit/f3c715c12412224be815e0d1bc3e2285f275df26))
+
+# [15.2.0](https://github.com/streamich/react-use/compare/v15.1.1...v15.2.0) (2020-06-07)
+
+
+### Features
+
+* add useMouseWheel hook ([d714b12](https://github.com/streamich/react-use/commit/d714b12e8b2d071c65fe4dc7643be10f69dc5dba))
+
+## [15.1.1](https://github.com/streamich/react-use/compare/v15.1.0...v15.1.1) (2020-05-30)
+
+
+### Bug Fixes
+
+* 🐛 use useIsomorphicLayoutEffect everywhere ([dad26e5](https://github.com/streamich/react-use/commit/dad26e507d3409300f945bc57930f88c5a11953d))
+
+# [15.1.0](https://github.com/streamich/react-use/compare/v15.0.3...v15.1.0) (2020-05-18)
+
+
+### Bug Fixes
+
+* display alert timeout in story ([2bb65ef](https://github.com/streamich/react-use/commit/2bb65ef3d85e82b6bd134a714e51e27876037734))
+* mutate ref in render directly ([5488f5e](https://github.com/streamich/react-use/commit/5488f5eb3e8504dcae03584b5797a48659e16623))
+
+
+### Features
+
+* add useLatest hook ([d6fe267](https://github.com/streamich/react-use/commit/d6fe2676153f19302ce170b03ceadc3bab5a945a))
+
+## [15.0.3](https://github.com/streamich/react-use/compare/v15.0.2...v15.0.3) (2020-05-18)
+
+
+### Bug Fixes
+
+* 🐛 correct useMeasure typings ([bedbad7](https://github.com/streamich/react-use/commit/bedbad723171ed1946bc80f72609432983d4c1ba))
+
+## [15.0.2](https://github.com/streamich/react-use/compare/v15.0.1...v15.0.2) (2020-05-17)
+
+
+### Bug Fixes
+
+* 🐛 dont memoize useScratch event handlers ([ffc7579](https://github.com/streamich/react-use/commit/ffc75790e329cb26000a174074c07d80283b5443))
+
+## [15.0.1](https://github.com/streamich/react-use/compare/v15.0.0...v15.0.1) (2020-05-16)
+
+
+### Bug Fixes
+
+* **deps:** update dependency tslib to v2 ([6aebf3c](https://github.com/streamich/react-use/commit/6aebf3c25e14d12d8f34e62ecbaecfd3125cf2d9))
+
+# [15.0.0](https://github.com/streamich/react-use/compare/v14.3.0...v15.0.0) (2020-05-16)
+
+
+* v15 release ([0f82ba6](https://github.com/streamich/react-use/commit/0f82ba650ed3e8b05b5458a243e7eb246fd954d2))
+
+
+### Bug Fixes
+
+* 🐛 better serialization handling in useLocalStorage hook ([68fb835](https://github.com/streamich/react-use/commit/68fb835ea64cf5587c99645a09c6de93ab1b71df))
+* 🐛 correctly test if env is browser in useMeasure ([9ae494f](https://github.com/streamich/react-use/commit/9ae494fc1874619aad2f3856df790cbc1a2a8239))
+* 🐛 make useMeasure work on server ([2daf769](https://github.com/streamich/react-use/commit/2daf76990d0e1040f8c0f31e16e7c1eebd94c9bf))
+* 🐛 remove set dependencies in useSet hook ([90ba9d0](https://github.com/streamich/react-use/commit/90ba9d000ff35039028cb66753114a6b0b452491))
+* 🐛 revert useMeasure defaults to zeros ([dc92b64](https://github.com/streamich/react-use/commit/dc92b646d0cd0f12868fde370c83e94ca3c7e297))
+* remove console log 🤓 ([f17c8a0](https://github.com/streamich/react-use/commit/f17c8a0f8e63bfddb8f13a094edbea1e3ee9680b))
+* **useLocalStorage:** using undefined for empty value instead of null ([1620e01](https://github.com/streamich/react-use/commit/1620e019fff94fb4a7a711fd3121ec02c7e99301))
+* use latest set object in useSet "has" method ([41f9452](https://github.com/streamich/react-use/commit/41f9452722d6fb7d2628480d7ce657e4f08e441a))
+
+
+### Features
+
+* 🎸 add useScratch() sensor hook ([58db2f9](https://github.com/streamich/react-use/commit/58db2f989d5d4f75ac5e8ef54c25a9df8bb173a5))
+* 🎸 catch up with v14 ([be69035](https://github.com/streamich/react-use/commit/be69035caf13f551e7717d3de0ea339c8943a9de))
+* 🎸 improve implementation of useMeasure() hook ([a164843](https://github.com/streamich/react-use/commit/a1648439021a45c781c2074489d7c6aaaa867406))
+* 🎸 improve implementation of useMeasure() hook ([4d88240](https://github.com/streamich/react-use/commit/4d8824064a0afbeba5a15597b007f8463fdbe027))
+* 🎸 mock useMeasure() hook on server and w/o ResizeObserver ([866f3d7](https://github.com/streamich/react-use/commit/866f3d740b08d4772dfbad9c48b3b0b8bac69a28))
+* 🎸 mock useMeasure() hook on server and w/o ResizeObserver ([2bbc73a](https://github.com/streamich/react-use/commit/2bbc73a5f08e9a21bb3054527fc8ff9fd51cfd47))
+* 🎸 remove resize-observer-polyfill from useMeasure ([2a13fba](https://github.com/streamich/react-use/commit/2a13fbae45af3a26c984de03130139181c0c3839))
+* 🎸 remove resize-observer-polyfill from useMeasure ([bf11131](https://github.com/streamich/react-use/commit/bf11131052c4a4ab2b9306486f0b171ac15057b0))
+* Dependencies inference for useCustomCompareEffect ([477c164](https://github.com/streamich/react-use/commit/477c1644a7225513c53294337be3c5b50126712f))
+* improve useAsyncFn and useAsync typings ([85967e2](https://github.com/streamich/react-use/commit/85967e294ce268bd1edc57968f2c3f85a3ee6cb7))
+* keep previous state in useAsyncFn ([54ac91b](https://github.com/streamich/react-use/commit/54ac91b28dca0f5c276b092d563b9c821cbab081))
+* use useReducer in useUpdate hook, instead of useState + useCallback ([6575b14](https://github.com/streamich/react-use/commit/6575b14985ede9b8f45fdad068ee9238d6f7ab80))
+* **useLocalStorage:** add remove feature. ([#229](https://github.com/streamich/react-use/issues/229)) ([587de16](https://github.com/streamich/react-use/commit/587de16ef5c85497d01e63247a578116d0605ff9))
+
+
+### BREAKING CHANGES
+
+* implementation of useMeasure and useLocalStorage changed
+* resize-observer-polyfill package is not used with useMeasure() hook
+anymore.
+* useMeasure() now defaults all values to -1, if they were not set and
+internal implementation heavily refactored.
+* useAsyncFn now keeps hold of old result/error when called multiple times
+* resize-observer-polyfill package is not used with useMeasure() hook
+anymore.
+* useMeasure() now defaults all values to -1, if they were not set and
+internal implementation heavily refactored.
+
+# [14.3.0](https://github.com/streamich/react-use/compare/v14.2.0...v14.3.0) (2020-05-16)
+
+
+### Features
+
+* 🎸 add useScratch hook ([2a2a298](https://github.com/streamich/react-use/commit/2a2a298b73f7beb9a2a61c309e649be3d2527473))
+
+# [14.2.0](https://github.com/streamich/react-use/compare/v14.1.1...v14.2.0) (2020-04-24)
+
+
+### Features
+
+* 🎸 onScrubStop provide value where scrub stopped ([138b43c](https://github.com/streamich/react-use/commit/138b43cd1ac9ea7c76a1a42fca48ebdcb94e1006))
+
+## [14.1.1](https://github.com/streamich/react-use/compare/v14.1.0...v14.1.1) (2020-04-11)
+
+
+### Bug Fixes
+
+* **deps:** update dependency @types/js-cookie to v2.2.6 ([f9f4fae](https://github.com/streamich/react-use/commit/f9f4fae6a9a136fdd6763dd2b2214c1746fb0595))
+
+# [14.1.0](https://github.com/streamich/react-use/compare/v14.0.0...v14.1.0) (2020-04-08)
+
+
+### Features
+
+* add useHash hook ([44a6cde](https://github.com/streamich/react-use/commit/44a6cde00e1c74831d7c38b8ae4946f6f2171cf5))
+
+# [14.0.0](https://github.com/streamich/react-use/compare/v13.27.1...v14.0.0) (2020-04-04)
+
+
+### Features
+
+* **useRafLoop:** implement [#1090](https://github.com/streamich/react-use/issues/1090) ([1ef1272](https://github.com/streamich/react-use/commit/1ef1272d6dbe8fbcc2d08223cd80ef32ce28a9c9))
+* **useRafLoop:** reworked the hook, now it do not re-render parent component. ([baa2f75](https://github.com/streamich/react-use/commit/baa2f7511e18fc9fec29376afa27af73de633d8f))
+
+
+### BREAKING CHANGES
+
+* **useRafLoop:** changed return array, now it returns only functions in next order: [stop, start, isActive].
+
+Parent component is not re-rendered on loop start/stop.
+
+## [13.27.1](https://github.com/streamich/react-use/compare/v13.27.0...v13.27.1) (2020-03-25)
+
+
+### Bug Fixes
+
+* **deps:** update dependency @xobotyi/scrollbar-width to v1.9.5 ([9751390](https://github.com/streamich/react-use/commit/97513900de7b60d8da62db35125e2f81458a4f25))
+
+# [13.27.0](https://github.com/streamich/react-use/compare/v13.26.5...v13.27.0) (2020-03-03)
+
+
+### Features
+
+* **useSet:** add toggle a method ([#968](https://github.com/streamich/react-use/issues/968)) ([477614f](https://github.com/streamich/react-use/commit/477614f9ef84d3cfa75f9c8a97dbc73d30dd411d))
+
+## [13.26.5](https://github.com/streamich/react-use/compare/v13.26.4...v13.26.5) (2020-03-02)
+
+
+### Bug Fixes
+
+* **deps:** update dependency @xobotyi/scrollbar-width to v1.9.4 ([29d017b](https://github.com/streamich/react-use/commit/29d017b2417f53455ee182aa1ad9574a3ee098d6))
+
+## [13.26.4](https://github.com/streamich/react-use/compare/v13.26.3...v13.26.4) (2020-02-29)
+
+
+### Bug Fixes
+
+* useHoverDirty eslint fix ([0ed6521](https://github.com/streamich/react-use/commit/0ed6521179fe193007f504b3b221a6c5295f9fa0))
+
+## [13.26.3](https://github.com/streamich/react-use/compare/v13.26.2...v13.26.3) (2020-02-26)
+
+
+### Bug Fixes
+
+* **deps:** update dependency @types/js-cookie to v2.2.5 ([1f3217a](https://github.com/streamich/react-use/commit/1f3217a07f0b11ed4d6264687188f587501c133b))
+
+## [13.26.2](https://github.com/streamich/react-use/compare/v13.26.1...v13.26.2) (2020-02-24)
+
+
+### Bug Fixes
+
+* **deps:** update dependency @xobotyi/scrollbar-width to v1.9.3 ([6e2287d](https://github.com/streamich/react-use/commit/6e2287d7e84ef1e455da7209ee32cf86643b00a5))
+
+## [13.26.1](https://github.com/streamich/react-use/compare/v13.26.0...v13.26.1) (2020-02-16)
+
+
+### Bug Fixes
+
+* **deps:** update dependency @xobotyi/scrollbar-width to v1.9.0 ([601d787](https://github.com/streamich/react-use/commit/601d7871a0325677a24a7a93fc9ce2b11132370f))
+
+# [13.26.0](https://github.com/streamich/react-use/compare/v13.25.1...v13.26.0) (2020-02-15)
+
+
+### Bug Fixes
+
+* add initialState to deps ([b394f3d](https://github.com/streamich/react-use/commit/b394f3d72356d331dbce48acd3686bbb64d331b5))
+
+
+### Features
+
+* add useMethods state hook ([7554b9a](https://github.com/streamich/react-use/commit/7554b9a61eb9b4744b9feb113775ff538b16beaf))
+
+## [13.25.1](https://github.com/streamich/react-use/compare/v13.25.0...v13.25.1) (2020-02-15)
+
+
+### Bug Fixes
+
+* 🐛 support default event in useClickAway() ([24281cd](https://github.com/streamich/react-use/commit/24281cdf042da5f83068c6108c67a36fe0cfc74d))
+* generic type on event arg in onClickAway callback on useClickAway ([4ffe454](https://github.com/streamich/react-use/commit/4ffe4542aec840bd6150223489d2c38821954336))
+
+# [13.25.0](https://github.com/streamich/react-use/compare/v13.24.1...v13.25.0) (2020-02-15)
+
+
+### Features
+
+* **useBeforeUnload:** allow passing a dirty function ([#842](https://github.com/streamich/react-use/issues/842)) ([c4a14a4](https://github.com/streamich/react-use/commit/c4a14a4fb370c7628e4cc5861e31cc64a66b64b0))
+
+## [13.24.1](https://github.com/streamich/react-use/compare/v13.24.0...v13.24.1) (2020-02-15)
+
+
+### Performance Improvements
+
+* use fast-deep-equal for deep comparisons ([b9a8aad](https://github.com/streamich/react-use/commit/b9a8aad053a40028f119192ddecedb5c7ec05247))
+
+# [13.24.0](https://github.com/streamich/react-use/compare/v13.23.0...v13.24.0) (2020-02-04)
+
+
+### Features
+
+* add createReducerContext and createStateContext factories ([84b8310](https://github.com/streamich/react-use/commit/84b83101c2253f8935b2804a48ade081e41982a8))
+
+# [13.23.0](https://github.com/streamich/react-use/compare/v13.22.5...v13.23.0) (2020-02-04)
+
+
+### Features
+
+* add createGlobalState hook generator ([fda7199](https://github.com/streamich/react-use/commit/fda7199b7da23f321e68d0784deb1f0f3d273e3c))
+
+## [13.22.5](https://github.com/streamich/react-use/compare/v13.22.4...v13.22.5) (2020-02-04)
+
+
+### Bug Fixes
+
+* 🐛 don't throw in useMediaDevices on missing browser API ([0f119fe](https://github.com/streamich/react-use/commit/0f119fe23e837e0d8c2a8c882b1aaf3b62cbc7d2))
+* handle undefined mediaDevices ([6f68437](https://github.com/streamich/react-use/commit/6f68437359704dace7d518f1f013bc3516400c67))
+
+## [13.22.4](https://github.com/streamich/react-use/compare/v13.22.3...v13.22.4) (2020-01-30)
+
+
+### Bug Fixes
+
+* **deps:** update dependency @xobotyi/scrollbar-width to v1.8.2 ([#930](https://github.com/streamich/react-use/issues/930)) ([727b950](https://github.com/streamich/react-use/commit/727b95096ec6654ba4da22f6825e6d8982258033))
+
+## [13.22.3](https://github.com/streamich/react-use/compare/v13.22.2...v13.22.3) (2020-01-28)
+
+
+### Bug Fixes
+
+* **useIntersection:** disconnect an old IntersectionObserver instance when the ref changes ([ac2f54a](https://github.com/streamich/react-use/commit/ac2f54a8f683296feecfeeb6354738b9ebbc36d0))
+* **useIntersection:** reset an intersectionObserverEntry when the ref changes ([3f8687e](https://github.com/streamich/react-use/commit/3f8687e1f51cc48efbf6be3f0677f5bd06ecba08))
+* **useIntersection:** return null if IntersectionObserver is not supported ([4f6d388](https://github.com/streamich/react-use/commit/4f6d3887be5cf62ce42357a7bf27f4ae8b080eba))
+
+## [13.22.2](https://github.com/streamich/react-use/compare/v13.22.1...v13.22.2) (2020-01-27)
+
+
+### Bug Fixes
+
+* **deps:** update dependency @xobotyi/scrollbar-width to v1.7.0 ([db74101](https://github.com/streamich/react-use/commit/db741019324c3d20a17bbc20a014cedd21e66b1a))
+
+## [13.22.1](https://github.com/streamich/react-use/compare/v13.22.0...v13.22.1) (2020-01-27)
+
+
+### Bug Fixes
+
+* **deps:** update dependency @xobotyi/scrollbar-width to v1.6.0 ([431ba5d](https://github.com/streamich/react-use/commit/431ba5d0816cb7701b03460c5efa5199ad27cbc4))
+
+# [13.22.0](https://github.com/streamich/react-use/compare/v13.21.0...v13.22.0) (2020-01-24)
+
+
+### Bug Fixes
+
+* Fail testing and update doc ([57b9041](https://github.com/streamich/react-use/commit/57b904118e2cd1f1b4e367c9a14e2a981db2f06a))
+
+
+### Features
+
+* add useLongPress hook ([45681b8](https://github.com/streamich/react-use/commit/45681b88e3fd3d9337a38da07248c46ec6d5956e))
+
+# [13.21.0](https://github.com/streamich/react-use/compare/v13.20.0...v13.21.0) (2020-01-20)
+
+
+### Features
+
+* Typings for `useDefault` ([fa0f53b](https://github.com/streamich/react-use/commit/fa0f53bf86a712f4b7e503cdf4718a8ff5448e05))
+
+# [13.20.0](https://github.com/streamich/react-use/compare/v13.19.0...v13.20.0) (2020-01-17)
+
+
+### Features
+
+* `useMap`: allow resetting with provided value other then initial ([7645f72](https://github.com/streamich/react-use/commit/7645f7249dbf52db140dfc8b7866cb4a171e439c))
+
+# [13.19.0](https://github.com/streamich/react-use/compare/v13.18.0...v13.19.0) (2020-01-16)
+
+
+### Features
+
+* add useError hook ([65f3644](https://github.com/streamich/react-use/commit/65f364420524bacebe8f8149b8197fb62bff1a08))
+
+# [13.18.0](https://github.com/streamich/react-use/compare/v13.17.0...v13.18.0) (2020-01-16)
+
+
+### Bug Fixes
+
+* check for null ([d619c39](https://github.com/streamich/react-use/commit/d619c39a21e9f0b4b4bfc6a209311bf0bd495f9b))
+
+
+### Features
+
+* add serializer/deserializer option to useLocalStorage ([5316510](https://github.com/streamich/react-use/commit/5316510babf7606a2f4b78de2b0eb85c930890cf))
+
+# [13.17.0](https://github.com/streamich/react-use/compare/v13.16.1...v13.17.0) (2020-01-15)
+
+
+### Features
+
+* add support for body lock on iOS ([d778408](https://github.com/streamich/react-use/commit/d7784084fe84aca72efe85260101b00ef1df7580))
+
+## [13.16.1](https://github.com/streamich/react-use/compare/v13.16.0...v13.16.1) (2020-01-14)
+
+
+### Bug Fixes
+
+* update the types dep for js-cookie ([5c55d59](https://github.com/streamich/react-use/commit/5c55d59a7d1d799cba7af87e15ab4a4b27a8fc67))
+
+# [13.16.0](https://github.com/streamich/react-use/compare/v13.15.0...v13.16.0) (2020-01-14)
+
+
+### Features
+
+* add option to useTitle to restore title on un-mount ([b8b3e47](https://github.com/streamich/react-use/commit/b8b3e479cea6071d4310bac29f138bd8917eee0b))
+
+# [13.15.0](https://github.com/streamich/react-use/compare/v13.14.3...v13.15.0) (2020-01-13)
+
+
+### Features
+
+* add useCookie hook ([4e5c90f](https://github.com/streamich/react-use/commit/4e5c90f021f56ae2008dc25daad69c43063f608f))
+
+## [13.14.3](https://github.com/streamich/react-use/compare/v13.14.2...v13.14.3) (2020-01-08)
+
+
+### Bug Fixes
+
+* useUpdateEffect cleanup test returns false positive ([9b31c42](https://github.com/streamich/react-use/commit/9b31c42ccb42fe13fc24f7434b00a1bcbee8cd8a))
+* useUpdateEffect test returning false positive ([#865](https://github.com/streamich/react-use/issues/865)) ([1946006](https://github.com/streamich/react-use/commit/1946006c4224bc61eabb797f4cdd7d20fff7ab25))
+
+## [13.14.2](https://github.com/streamich/react-use/compare/v13.14.1...v13.14.2) (2020-01-08)
+
+
+### Bug Fixes
+
+* bump fast-shallow-equal ([19b2b39](https://github.com/streamich/react-use/commit/19b2b39eeae3898bd8d8e3478eb7459372bb09d5))
+
+## [13.14.1](https://github.com/streamich/react-use/compare/v13.14.0...v13.14.1) (2020-01-07)
+
+
+### Bug Fixes
+
+* useUpdateEffect returns optional cleanup function ([0ce421c](https://github.com/streamich/react-use/commit/0ce421ced78fd6eb06a5676fefb856e18bfcacc1))
+* useUpdateEffect returns optional cleanup function ([#864](https://github.com/streamich/react-use/issues/864)) ([7960127](https://github.com/streamich/react-use/commit/7960127a98c0d3c33000088fbd97804d41084f7d))
+
+# [13.14.0](https://github.com/streamich/react-use/compare/v13.13.0...v13.14.0) (2020-01-03)
+
+
+### Features
+
+* 🎸 add [vertical] flag to useSlider() hook ([777865c](https://github.com/streamich/react-use/commit/777865c3ac6772fbda2bc0a6f58cde3eff7dec43))
+
+# [13.13.0](https://github.com/streamich/react-use/compare/v13.12.2...v13.13.0) (2019-12-27)
+
+
+### Features
+
+* add useShallowCompareEffect and useCustomCompareEffect hooks ([ba8803e](https://github.com/streamich/react-use/commit/ba8803eab26d2d48028a4b7120a7354c6d318aea))
+
+## [13.12.2](https://github.com/streamich/react-use/compare/v13.12.1...v13.12.2) (2019-12-10)
+
+
+### Bug Fixes
+
+* **useSet:** "has" method in useSet updated to reference latest set object ([4f1d8c2](https://github.com/streamich/react-use/commit/4f1d8c2cbd773f2a26e2eee4fbad88883ea4b405))
+
+## [13.12.1](https://github.com/streamich/react-use/compare/v13.12.0...v13.12.1) (2019-12-09)
+
+
+### Bug Fixes
+
+* **useMap:** methods with side effects should be stable across renders. ([020b4db](https://github.com/streamich/react-use/commit/020b4dbc6c47ab25243ab8af257dd045e6c1bf6d))
+
+# [13.12.0](https://github.com/streamich/react-use/compare/v13.11.0...v13.12.0) (2019-12-09)
+
+
+### Features
+
+* useScrollbarWidth hook; ([#825](https://github.com/streamich/react-use/issues/825)) ([125c7e9](https://github.com/streamich/react-use/commit/125c7e96a188405aea36e94ed1bb3d984232b2f6))
+
+# [13.11.0](https://github.com/streamich/react-use/compare/v13.10.2...v13.11.0) (2019-12-08)
+
+
+### Features
+
+* 🎸 add useUnmountPromise hook ([01421bc](https://github.com/streamich/react-use/commit/01421bc634b941044e95c611f37eb87339486241))
+
+## [13.10.2](https://github.com/streamich/react-use/compare/v13.10.1...v13.10.2) (2019-12-05)
+
+
+### Bug Fixes
+
+* useUpdate hitting maxInt, failing to trigger rerender ([93e7291](https://github.com/streamich/react-use/commit/93e72910abf2dafe5bdff625a21f633afd6e52c5))
+
+## [13.10.1](https://github.com/streamich/react-use/compare/v13.10.0...v13.10.1) (2019-12-03)
+
+
+### Bug Fixes
+
+* "get" method in useMap updated to reference latest map object ([044d267](https://github.com/streamich/react-use/commit/044d2677aa474d19da776444b78bd3d2594c6ae5))
+
+# [13.10.0](https://github.com/streamich/react-use/compare/v13.9.0...v13.10.0) (2019-11-28)
+
+
+### Features
+
+* useStateHistory ([#709](https://github.com/streamich/react-use/issues/709)) ([0a66359](https://github.com/streamich/react-use/commit/0a6635914319e9ef7a2902189a3c2dea90a2bf7f))
+
+# [13.9.0](https://github.com/streamich/react-use/compare/v13.8.2...v13.9.0) (2019-11-23)
+
+
+### Features
+
+* add useFirstMountState & useRendersCount hooks ([#769](https://github.com/streamich/react-use/issues/769)) ([30abe2b](https://github.com/streamich/react-use/commit/30abe2b22e3cb7a3e4c6dedd2466d74ce660911d))
+
+## [13.8.2](https://github.com/streamich/react-use/compare/v13.8.1...v13.8.2) (2019-11-22)
+
+
+### Bug Fixes
+
+* **#792:** make useUnmount invoke the current callback version instead of very first ([75284c6](https://github.com/streamich/react-use/commit/75284c62c8e4a68dfeb41a8d98a1e636e9ef531a)), closes [#792](https://github.com/streamich/react-use/issues/792)
+
+## [13.8.1](https://github.com/streamich/react-use/compare/v13.8.0...v13.8.1) (2019-11-21)
+
+
+### Bug Fixes
+
+* useAsyncFn does not discard old promises and might produce races ([022fa0b](https://github.com/streamich/react-use/commit/022fa0b7b77d582a10c6ca61a3dcd901770011c8))
+
+# [13.8.0](https://github.com/streamich/react-use/compare/v13.7.0...v13.8.0) (2019-11-14)
+
+
+### Features
+
+* **useStateValidator:** Refactor method and improve typings; ([436c210](https://github.com/streamich/react-use/commit/436c210f7b577c6958e47df3a244907b07a4db9f))
+
+# [13.7.0](https://github.com/streamich/react-use/compare/v13.6.3...v13.7.0) (2019-11-14)
+
+
+### Features
+
+* Add useSet hook ([095b4de](https://github.com/streamich/react-use/commit/095b4de2321b8bf3431e3f66139629b0495f1ac9))
+
+## [13.6.3](https://github.com/streamich/react-use/compare/v13.6.2...v13.6.3) (2019-11-12)
+
+
+### Bug Fixes
+
+* remove any types in useThrottleFn ([bb5baea](https://github.com/streamich/react-use/commit/bb5baea30cf59721098ca9e3185105bf1b82218b))
+
+## [13.6.2](https://github.com/streamich/react-use/compare/v13.6.1...v13.6.2) (2019-11-11)
+
+
+### Bug Fixes
+
+* restrict useThrottleFn types ([61a83d1](https://github.com/streamich/react-use/commit/61a83d124d35d5606b6c0700faf1361fd3170ca4))
+
+## [13.6.1](https://github.com/streamich/react-use/compare/v13.6.0...v13.6.1) (2019-11-10)
+
+
+### Bug Fixes
+
+* 🐛 check window.Event constructor exists in useLocation ([ad09431](https://github.com/streamich/react-use/commit/ad094311454c48873ba7143654a29b8a0c54459d))
+
+# [13.6.0](https://github.com/streamich/react-use/compare/v13.5.0...v13.6.0) (2019-11-10)
+
+
+### Features
+
+* **useCounter:** `reset` to the newest initialValue ([#667](https://github.com/streamich/react-use/issues/667)) ([e653383](https://github.com/streamich/react-use/commit/e65338372adfccd4800496b377f63bcdf6646788))
+
+# [13.5.0](https://github.com/streamich/react-use/compare/v13.4.0...v13.5.0) (2019-11-08)
+
+
+### Bug Fixes
+
+* **resolveHookState:** by accident removed needed type. ([59aa41c](https://github.com/streamich/react-use/commit/59aa41cff435f5adf7f38d361649761b8dd69794))
+
+
+### Features
+
+* **useList:** reimplemented useList hook; ([1840b57](https://github.com/streamich/react-use/commit/1840b577e2a3d321b8dbb44d5ae443e84d4d9e20))
+
+# [13.4.0](https://github.com/streamich/react-use/compare/v13.3.0...v13.4.0) (2019-11-08)
+
+
+### Features
+
+* **useStateList:** implemented `currentIndex`, `setState`, `setStateAt` methods as requested in [#634](https://github.com/streamich/react-use/issues/634); ([43cb6aa](https://github.com/streamich/react-use/commit/43cb6aa612ae869e24f67acf6f0a1712a65f128b))
+
+# [13.3.0](https://github.com/streamich/react-use/compare/v13.2.2...v13.3.0) (2019-11-06)
+
+
+### Features
+
+* useDebounce add cancel ([693aec8](https://github.com/streamich/react-use/commit/693aec8307c378697c88c635a401832f24d3531a))
+* useDebounce add cancel ([26cab31](https://github.com/streamich/react-use/commit/26cab31f10a995ec45d6c1e2a2f724d9994d801f))
+
+## [13.2.2](https://github.com/streamich/react-use/compare/v13.2.1...v13.2.2) (2019-11-06)
+
+
+### Bug Fixes
+
+* **#749:** now should work with SSR ([c12976c](https://github.com/streamich/react-use/commit/c12976cad26577a4be3ac65133268f41bbdc82da)), closes [#749](https://github.com/streamich/react-use/issues/749)
+
+## [13.2.1](https://github.com/streamich/react-use/compare/v13.2.0...v13.2.1) (2019-11-04)
+
+
+### Bug Fixes
+
+* **yarn.lock:** re-create the yarn.lock file with nailed versions in devDeps ([f094a3a](https://github.com/streamich/react-use/commit/f094a3ae833f406137b9d5355843a6615af20164))
+
+# [13.2.0](https://github.com/streamich/react-use/compare/v13.1.0...v13.2.0) (2019-11-04)
+
+
+### Features
+
+* re-create yarn.lock ([d48e03e](https://github.com/streamich/react-use/commit/d48e03e9ee38555ff29ca46fb6e75c13e9c23aba))
+* re-create yarn.lock ([ccdffe0](https://github.com/streamich/react-use/commit/ccdffe027fba15bdca1f35dc375a0c32739aee6f))
+* **usePreviousDistinct:** add tests for undefined value behaviour; ([cb373f9](https://github.com/streamich/react-use/commit/cb373f951fb3f34b9e54793687de14000a2dc08e))
+* **usePreviousDistinct:** improve types; ([30f53e8](https://github.com/streamich/react-use/commit/30f53e8c5d7e8b27bf3f273ebfcacabf30146ba3))
+* **usePreviousDistinct:** now predicate not called on initial render; ([fbe9b13](https://github.com/streamich/react-use/commit/fbe9b1303c0433d5608ca5b507d9c76711b5cb68))
+* **useStateList:** rework useStateList to make it work properly. ([242c274](https://github.com/streamich/react-use/commit/242c274dd49779fa80f8b9e451c699205279339e))
+* **useTitle:** reworked hook to make it synchronous without useUpdate; ([a133267](https://github.com/streamich/react-use/commit/a13326779ffd6885ac531240b984a77bcad3bee6))
+* **useWindowSize:** A bit changed lyfecycle and added types; ([03bdecf](https://github.com/streamich/react-use/commit/03bdecf7ac6aa0ad863a1efd71c056aa41df62b7))
+
+# [13.1.0](https://github.com/streamich/react-use/compare/v13.0.1...v13.1.0) (2019-11-01)
+
+
+### Features
+
+* pull request template for features ([1dc21f3](https://github.com/streamich/react-use/commit/1dc21f3))
+
+## [13.0.1](https://github.com/streamich/react-use/compare/v13.0.0...v13.0.1) (2019-11-01)
+
+
+### Bug Fixes
+
+* **useLockBodyScroll:** infer overflow type directly from declaration. ([26baf47](https://github.com/streamich/react-use/commit/26baf47))
+
+# [13.0.0](https://github.com/streamich/react-use/compare/v12.13.0...v13.0.0) (2019-11-01)
+
+
+* Merge pull request #711 from streamich/remove-react-wait ([8d40f18](https://github.com/streamich/react-use/commit/8d40f18)), closes [#711](https://github.com/streamich/react-use/issues/711)
+
+
+### Features
+
+* remove useRefMounted hook ([ad74d3d](https://github.com/streamich/react-use/commit/ad74d3d))
+* **useRefMounted:** remove obsolete hook; ([dc364c8](https://github.com/streamich/react-use/commit/dc364c8))
+* **useWait:** removed from package due to it is simple reexport of other package; ([d7c38bd](https://github.com/streamich/react-use/commit/d7c38bd))
+
+
+### BREAKING CHANGES
+
+* useWait hook has been removed from react-use
+* deprecated useRefMounted hook is now removed, use useMountedState hook instead
+
+# [12.13.0](https://github.com/streamich/react-use/compare/v12.12.0...v12.13.0) (2019-10-31)
+
+
+### Features
+
+* **useCounter:** reworked with use of new resolveHookState function plus improved memory usage; ([befcf84](https://github.com/streamich/react-use/commit/befcf84))
+* **useGetSet:** reworked with use of new resolveHookState function plus improved memory usage; ([9b5d0f2](https://github.com/streamich/react-use/commit/9b5d0f2))
+* react-like state resolver to use it in stateful hooks; ([9fd02eb](https://github.com/streamich/react-use/commit/9fd02eb))
+
+# [12.12.0](https://github.com/streamich/react-use/compare/v12.11.0...v12.12.0) (2019-10-31)
+
+
+### Features
+
+* add typings for createReducer ([f1cf036](https://github.com/streamich/react-use/commit/f1cf036))
+
+# [12.11.0](https://github.com/streamich/react-use/compare/v12.10.0...v12.11.0) (2019-10-31)
+
+
+### Features
+
+* **useWait:** add deprecation messages to readme and export; ([d338245](https://github.com/streamich/react-use/commit/d338245))
+
+# [12.10.0](https://github.com/streamich/react-use/compare/v12.9.1...v12.10.0) (2019-10-30)
+
+
+### Features
+
+* **useUpdate:** improve memory usage - now single function instance to increment all counters; ([0f02fd0](https://github.com/streamich/react-use/commit/0f02fd0))
+
+## [12.9.1](https://github.com/streamich/react-use/compare/v12.9.0...v12.9.1) (2019-10-28)
+
+
+### Bug Fixes
+
+* useSize avoid crash in Safari 11 ([da0e66b](https://github.com/streamich/react-use/commit/da0e66b))
+
+# [12.9.0](https://github.com/streamich/react-use/compare/v12.8.0...v12.9.0) (2019-10-26)
+
+
+### Features
+
+* add createBreakpoint ([79ba4ef](https://github.com/streamich/react-use/commit/79ba4ef))
+
+# [12.8.0](https://github.com/streamich/react-use/compare/v12.7.2...v12.8.0) (2019-10-25)
+
+
+### Features
+
+* add ensuredForwardRef and useEnsuredForwardedRef ([1bfe063](https://github.com/streamich/react-use/commit/1bfe063))
+
+## [12.7.2](https://github.com/streamich/react-use/compare/v12.7.1...v12.7.2) (2019-10-23)
+
+
+### Bug Fixes
+
+* 🐛 bump set-harmonic-interval package version ([f7c709a](https://github.com/streamich/react-use/commit/f7c709a))
+
+## [12.7.1](https://github.com/streamich/react-use/compare/v12.7.0...v12.7.1) (2019-10-17)
+
+
+### Bug Fixes
+
+* example in the docs; ([7f54cad](https://github.com/streamich/react-use/commit/7f54cad))
+* rename story's mediator and add `g` flag to it's regex; ([652b318](https://github.com/streamich/react-use/commit/652b318))
+
+# [12.7.0](https://github.com/streamich/react-use/compare/v12.6.0...v12.7.0) (2019-10-17)
+
+
+### Bug Fixes
+
+* error throw tests; ([056875b](https://github.com/streamich/react-use/commit/056875b))
+* useMultiStateValidator readme description; ([8c7f7f5](https://github.com/streamich/react-use/commit/8c7f7f5))
+
+
+### Features
+
+* useMultiStateValidator ([ae26988](https://github.com/streamich/react-use/commit/ae26988))
+
+# [12.6.0](https://github.com/streamich/react-use/compare/v12.5.0...v12.6.0) (2019-10-16)
+
+
+### Features
+
+* useRafState ([#684](https://github.com/streamich/react-use/issues/684)) ([00816a4](https://github.com/streamich/react-use/commit/00816a4))
+
+# [12.5.0](https://github.com/streamich/react-use/compare/v12.4.0...v12.5.0) (2019-10-13)
+
+
+### Features
+
+* useList allow pushing multiple items ([#621](https://github.com/streamich/react-use/issues/621)) ([a624364](https://github.com/streamich/react-use/commit/a624364))
+
+# [12.4.0](https://github.com/streamich/react-use/compare/v12.3.2...v12.4.0) (2019-10-12)
+
+
+### Features
+
+* useIntersection ([#652](https://github.com/streamich/react-use/issues/652)) ([d5f359f](https://github.com/streamich/react-use/commit/d5f359f))
+
+## [12.3.2](https://github.com/streamich/react-use/compare/v12.3.1...v12.3.2) (2019-10-12)
+
+
+### Bug Fixes
+
+* improve use of refs in dependency lists ([#655](https://github.com/streamich/react-use/issues/655)) ([ed8e26d](https://github.com/streamich/react-use/commit/ed8e26d))
+
+## [12.3.1](https://github.com/streamich/react-use/compare/v12.3.0...v12.3.1) (2019-10-10)
+
+
+### Bug Fixes
+
+* move [@types](https://github.com/types)/react-wait to dependencies, closes [#661](https://github.com/streamich/react-use/issues/661) ([#662](https://github.com/streamich/react-use/issues/662)) ([6bdd74e](https://github.com/streamich/react-use/commit/6bdd74e))
+
+# [12.3.0](https://github.com/streamich/react-use/compare/v12.2.3...v12.3.0) (2019-10-07)
+
+
+### Features
+
+* reset util callback for useList ([#654](https://github.com/streamich/react-use/issues/654)) ([9ea3548](https://github.com/streamich/react-use/commit/9ea3548))
+
+## [12.2.3](https://github.com/streamich/react-use/compare/v12.2.2...v12.2.3) (2019-10-05)
+
+
+### Bug Fixes
+
+* move react-wait types to dev dependencies, closes [#644](https://github.com/streamich/react-use/issues/644) ([49372ac](https://github.com/streamich/react-use/commit/49372ac))
+
+## [12.2.2](https://github.com/streamich/react-use/compare/v12.2.1...v12.2.2) (2019-09-26)
+
+
+### Bug Fixes
+
+* useDebounce remove deps from function arguments ([#623](https://github.com/streamich/react-use/issues/623)) ([23d6a5a](https://github.com/streamich/react-use/commit/23d6a5a))
+
+## [12.2.1](https://github.com/streamich/react-use/compare/v12.2.0...v12.2.1) (2019-09-23)
+
+
+### Bug Fixes
+
+* remove attempt from deps of retry in useAsyncRetry ([#614](https://github.com/streamich/react-use/issues/614)) ([adce59e](https://github.com/streamich/react-use/commit/adce59e))
+
+# [12.2.0](https://github.com/streamich/react-use/compare/v12.1.0...v12.2.0) (2019-09-02)
+
+
+### Features
+
+* improve useWindowSize performance rAF ([60a4937](https://github.com/streamich/react-use/commit/60a4937))
+
+# [12.1.0](https://github.com/streamich/react-use/compare/v12.0.0...v12.1.0) (2019-09-01)
+
+
+### Features
+
+* 🎸 add useSearchParam() hook ([b22f32f](https://github.com/streamich/react-use/commit/b22f32f))
+* 🎸 support server-side rendering in useSearchParam() hook ([64ac924](https://github.com/streamich/react-use/commit/64ac924))
+
+# [12.0.0](https://github.com/streamich/react-use/compare/v11.3.2...v12.0.0) (2019-09-01)
+
+
+### Features
+
+* store "paused" instead of "isPlaying" in media state ([ff900d5](https://github.com/streamich/react-use/commit/ff900d5))
+
+
+### BREAKING CHANGES
+
+* now media players return "paused" instead of "isPlaying" in their state.
+
+## [11.3.2](https://github.com/streamich/react-use/compare/v11.3.1...v11.3.2) (2019-08-25)
+
+
+### Bug Fixes
+
+* useThrottle & useThrottleFn proper timeout type; ([e2cdb94](https://github.com/streamich/react-use/commit/e2cdb94))
+
+## [11.3.1](https://github.com/streamich/react-use/compare/v11.3.0...v11.3.1) (2019-08-25)
+
+
+### Bug Fixes
+
+* update createReducer to fix initial state ([fd083f2](https://github.com/streamich/react-use/commit/fd083f2))
+
+# [11.3.0](https://github.com/streamich/react-use/compare/v11.2.0...v11.3.0) (2019-08-25)
+
+
+### Features
+
+* add usePreviousDistinct ([#551](https://github.com/streamich/react-use/issues/551)) ([6c3e569](https://github.com/streamich/react-use/commit/6c3e569))
+
+# [11.2.0](https://github.com/streamich/react-use/compare/v11.1.1...v11.2.0) (2019-08-25)
+
+
+### Features
+
+* add useCircularIterate ([8d84340](https://github.com/streamich/react-use/commit/8d84340))
+
+## [11.1.1](https://github.com/streamich/react-use/compare/v11.1.0...v11.1.1) (2019-08-25)
+
+
+### Bug Fixes
+
+* [#550](https://github.com/streamich/react-use/issues/550) ([2617d74](https://github.com/streamich/react-use/commit/2617d74))
+
+# [11.1.0](https://github.com/streamich/react-use/compare/v11.0.2...v11.1.0) (2019-08-25)
+
+
+### Features
+
+* 🎸 add useHarmonicIntervalFn() hook ([d9f21e3](https://github.com/streamich/react-use/commit/d9f21e3))
+
+## [11.0.2](https://github.com/streamich/react-use/compare/v11.0.1...v11.0.2) (2019-08-23)
+
+
+### Bug Fixes
+
+* **useSetState:** memoize setState callback ([0275329](https://github.com/streamich/react-use/commit/0275329))
+* **useSetState:** memoize setState callback ([16f023f](https://github.com/streamich/react-use/commit/16f023f))
+
+## [11.0.1](https://github.com/streamich/react-use/compare/v11.0.0...v11.0.1) (2019-08-23)
+
+
+### Bug Fixes
+
+* correct useSpring() hook behaviour ([d7a622d](https://github.com/streamich/react-use/commit/d7a622d))
+
+# [11.0.0](https://github.com/streamich/react-use/compare/v10.8.0...v11.0.0) (2019-08-22)
+
+
+### Features
+
+* add cancel and reset methods to useTimeout ([283045a](https://github.com/streamich/react-use/commit/283045a))
+* add useTimeoutFn ([284e6fd](https://github.com/streamich/react-use/commit/284e6fd))
+
+
+### BREAKING CHANGES
+
+* useTimeout now returns a tuple
+
+# [10.8.0](https://github.com/streamich/react-use/compare/v10.7.1...v10.8.0) (2019-08-20)
+
+
+### Bug Fixes
+
+* Reworked useBattery hook ([1069060](https://github.com/streamich/react-use/commit/1069060))
+* succeed useRafLoop tests ([09167df](https://github.com/streamich/react-use/commit/09167df))
+
+
+### Features
+
+* 🎸 support useBattery hook on server side ([5d31cf0](https://github.com/streamich/react-use/commit/5d31cf0))
+* 🎸 use only one useState and one useEffect call ([2d0fabf](https://github.com/streamich/react-use/commit/2d0fabf))
+
+## [10.7.1](https://github.com/streamich/react-use/compare/v10.7.0...v10.7.1) (2019-08-20)
+
+
+### Bug Fixes
+
+* async test warnings ([#543](https://github.com/streamich/react-use/issues/543)) ([7af237e](https://github.com/streamich/react-use/commit/7af237e))
+
+# [10.7.0](https://github.com/streamich/react-use/compare/v10.6.4...v10.7.0) (2019-08-19)
+
+
+### Features
+
+* 🎸 add useUpsert ([6875e13](https://github.com/streamich/react-use/commit/6875e13))
+* 🎸 export useUpsert from index ([3eda2b2](https://github.com/streamich/react-use/commit/3eda2b2))
+* add useUpsert ([a7c2899](https://github.com/streamich/react-use/commit/a7c2899))
+
+## [10.6.4](https://github.com/streamich/react-use/compare/v10.6.3...v10.6.4) (2019-08-19)
+
+
+### Bug Fixes
+
+* return from useUpdateEffect ([2f70dc2](https://github.com/streamich/react-use/commit/2f70dc2))
+* useUpdateEffect add return ([8b24df4](https://github.com/streamich/react-use/commit/8b24df4))
+
+## [10.6.3](https://github.com/streamich/react-use/compare/v10.6.2...v10.6.3) (2019-08-19)
+
+
+### Bug Fixes
+
+* allow import default for ESM ([bd3a062](https://github.com/streamich/react-use/commit/bd3a062))
+* rollup build error: Cannot call a namespace ('writeText') ([b3e672b](https://github.com/streamich/react-use/commit/b3e672b))
+
+## [10.6.2](https://github.com/streamich/react-use/compare/v10.6.1...v10.6.2) (2019-08-18)
+
+
+### Bug Fixes
+
+* 🐛 fix master ([d1df7a5](https://github.com/streamich/react-use/commit/d1df7a5))
+
+## [10.6.1](https://github.com/streamich/react-use/compare/v10.6.0...v10.6.1) (2019-08-17)
+
+
+### Bug Fixes
+
+* useUpdateEffect run on the wrong time ([1d5cd10](https://github.com/streamich/react-use/commit/1d5cd10))
+
+# [10.6.0](https://github.com/streamich/react-use/compare/v10.5.0...v10.6.0) (2019-08-17)
+
+
+### Features
+
+* add min/max to useNumber ([586faab](https://github.com/streamich/react-use/commit/586faab))
+
+# [10.5.0](https://github.com/streamich/react-use/compare/v10.4.0...v10.5.0) (2019-08-03)
+
+
+### Features
+
+* add useRafLoop hook ([be7d7c3](https://github.com/streamich/react-use/commit/be7d7c3))
+
+# [10.4.0](https://github.com/streamich/react-use/compare/v10.3.1...v10.4.0) (2019-08-02)
+
+
+### Features
+
+* add useMountedState hook ([9081b99](https://github.com/streamich/react-use/commit/9081b99))
+
+## [10.3.1](https://github.com/streamich/react-use/compare/v10.3.0...v10.3.1) (2019-08-02)
+
+
+### Bug Fixes
+
+* **storybook:** fix useKeyboardJs import path ([b7481f6](https://github.com/streamich/react-use/commit/b7481f6))
+* **useKeyboardJs:** fix argument type error ([8c820ce](https://github.com/streamich/react-use/commit/8c820ce))
+* allow string list in useKeyboardJs hook ([aecbd0b](https://github.com/streamich/react-use/commit/aecbd0b))
+
+# [10.3.0](https://github.com/streamich/react-use/compare/v10.2.0...v10.3.0) (2019-07-26)
+
+
+### Features
+
+* add useDefault hook ([ade0557](https://github.com/streamich/react-use/commit/ade0557))
+
+# [10.2.0](https://github.com/streamich/react-use/compare/v10.1.2...v10.2.0) (2019-07-25)
+
+
+### Features
+
+* useWindowScroll - for cross-browser compatibility ([5987cc8](https://github.com/streamich/react-use/commit/5987cc8))
+* useWindowScroll - for cross-browser compatibility ([#480](https://github.com/streamich/react-use/issues/480)) ([e37dd8d](https://github.com/streamich/react-use/commit/e37dd8d))
+
+## [10.1.2](https://github.com/streamich/react-use/compare/v10.1.1...v10.1.2) (2019-07-21)
+
+
+### Bug Fixes
+
+* remove OpenCollective postinstall hook ([26dcebc](https://github.com/streamich/react-use/commit/26dcebc))
+
+## [10.1.1](https://github.com/streamich/react-use/compare/v10.1.0...v10.1.1) (2019-07-21)
+
+
+### Bug Fixes
+
+* useMouse & useMouseHovered type definitions for SVG ([9e97451](https://github.com/streamich/react-use/commit/9e97451))
+* useMouse & useMouseHovered type definitions for SVG ([#479](https://github.com/streamich/react-use/issues/479)) ([e2e4a60](https://github.com/streamich/react-use/commit/e2e4a60))
+
+# [10.1.0](https://github.com/streamich/react-use/compare/v10.0.0...v10.1.0) (2019-07-17)
+
+
+### Features
+
+* add latest `react-wait` types ([6ebe3bb](https://github.com/streamich/react-use/commit/6ebe3bb))
+
+# [10.0.0](https://github.com/streamich/react-use/compare/v9.12.0...v10.0.0) (2019-07-17)
+
+
+### Features
+
+* remove big libs from peerDependencies ([1dbdc5d](https://github.com/streamich/react-use/commit/1dbdc5d))
+
+
+### BREAKING CHANGES
+
+* `useSpring` and `useKeyboardJs` hooks need to be imported directly now and libs they depend on are not in peerDependencies anymore.
+
+# [9.12.0](https://github.com/streamich/react-use/compare/v9.11.2...v9.12.0) (2019-07-16)
+
+
+### Bug Fixes
+
+* 🐛 fix useDebounce import ([40b33da](https://github.com/streamich/react-use/commit/40b33da))
+
+
+### Features
+
+* add useInterval hook ([6645ed9](https://github.com/streamich/react-use/commit/6645ed9))
+
+## [9.11.2](https://github.com/streamich/react-use/compare/v9.11.1...v9.11.2) (2019-07-16)
+
+
+### Bug Fixes
+
+* support useMedia usage server-side ([50a5160](https://github.com/streamich/react-use/commit/50a5160))
+
+## [9.11.1](https://github.com/streamich/react-use/compare/v9.11.0...v9.11.1) (2019-07-16)
+
+
+### Bug Fixes
+
+* createReducer stable dispatch function identity ([9780545](https://github.com/streamich/react-use/commit/9780545))
+
+# [9.11.0](https://github.com/streamich/react-use/compare/v9.10.0...v9.11.0) (2019-07-11)
+
+
+### Features
+
+* useMedia - initialize state with call to media query ([#454](https://github.com/streamich/react-use/issues/454)) ([ab81897](https://github.com/streamich/react-use/commit/ab81897))
+
+# [9.10.0](https://github.com/streamich/react-use/compare/v9.9.0...v9.10.0) (2019-07-10)
+
+
+### Features
+
+* expose useIsomorphicLayoutEffect + docs ([#451](https://github.com/streamich/react-use/issues/451)) ([8dcbbf1](https://github.com/streamich/react-use/commit/8dcbbf1))
+
+# [9.9.0](https://github.com/streamich/react-use/compare/v9.8.3...v9.9.0) (2019-07-10)
+
+
+### Features
+
+* add usePermission ([4da40b9](https://github.com/streamich/react-use/commit/4da40b9))
+* usePermission ([588a0c5](https://github.com/streamich/react-use/commit/588a0c5))
+
+## [9.8.3](https://github.com/streamich/react-use/compare/v9.8.2...v9.8.3) (2019-07-10)
+
+
+### Bug Fixes
+
+* useLocalStorage types for functional updates ([e2b8278](https://github.com/streamich/react-use/commit/e2b8278))
+
+## [9.8.2](https://github.com/streamich/react-use/compare/v9.8.1...v9.8.2) (2019-07-08)
+
+
+### Bug Fixes
+
+* **useSize:** prevents accessing iframe's property when it's not defined ([c9b5cdc](https://github.com/streamich/react-use/commit/c9b5cdc)), closes [#442](https://github.com/streamich/react-use/issues/442)
+* **useSize:** prevents accessing iframe's property when it's not… ([#443](https://github.com/streamich/react-use/issues/443)) ([8f04e8f](https://github.com/streamich/react-use/commit/8f04e8f))
+* iframe can be null ([a9e3bab](https://github.com/streamich/react-use/commit/a9e3bab))
+
+## [9.8.1](https://github.com/streamich/react-use/compare/v9.8.0...v9.8.1) (2019-06-30)
+
+
+### Bug Fixes
+
+* lint fixes via lint:fix ([7ce8e4f](https://github.com/streamich/react-use/commit/7ce8e4f))
+* useMap uses prevMap state which is safer ([3554f79](https://github.com/streamich/react-use/commit/3554f79))
+* **useMap:** remove now also uses prevMap state to not overwrite or lose state ([0a59869](https://github.com/streamich/react-use/commit/0a59869))
+
+# [9.8.0](https://github.com/streamich/react-use/compare/v9.7.2...v9.8.0) (2019-06-30)
+
+
+### Bug Fixes
+
+* 🐛 fix test and add pre-push hook ([1353b6c](https://github.com/streamich/react-use/commit/1353b6c))
+
+
+### Features
+
+* add voice option in use speech ([6dc2dd5](https://github.com/streamich/react-use/commit/6dc2dd5))
+* add voice option in useSpeech ([#422](https://github.com/streamich/react-use/issues/422)) ([c32d02b](https://github.com/streamich/react-use/commit/c32d02b))
+
+## [9.7.2](https://github.com/streamich/react-use/compare/v9.7.1...v9.7.2) (2019-06-27)
+
+
+### Bug Fixes
+
+* save to localStorage only when state changes ([ba6d375](https://github.com/streamich/react-use/commit/ba6d375))
+* use correct list variable in useList ([#412](https://github.com/streamich/react-use/issues/412)) ([b937296](https://github.com/streamich/react-use/commit/b937296))
+
+## [9.7.1](https://github.com/streamich/react-use/compare/v9.7.0...v9.7.1) (2019-06-23)
+
+
+### Bug Fixes
+
+* 🐛 use synchronouse effect to subscribe to observables ([376eea3](https://github.com/streamich/react-use/commit/376eea3))
+
+# [9.7.0](https://github.com/streamich/react-use/compare/v9.6.0...v9.7.0) (2019-06-19)
+
+
+### Features
+
+* improve useClickAway() hook ([#394](https://github.com/streamich/react-use/issues/394)) ([c60df19](https://github.com/streamich/react-use/commit/c60df19))
+
+# [9.6.0](https://github.com/streamich/react-use/compare/v9.5.0...v9.6.0) (2019-06-18)
+
+
+### Bug Fixes
+
+* add additional ref check on clean up ([d18d2d8](https://github.com/streamich/react-use/commit/d18d2d8))
+* always return something from effect ([3355426](https://github.com/streamich/react-use/commit/3355426))
+
+
+### Features
+
+* 🎸 add useScrolling hook ([bd9928e](https://github.com/streamich/react-use/commit/bd9928e))
+* 🎸 add useScrolling hook to index ([b3ba702](https://github.com/streamich/react-use/commit/b3ba702))
+* add useScrolling docs ([25a93f6](https://github.com/streamich/react-use/commit/25a93f6))
+* add useScrolling story ([760edf1](https://github.com/streamich/react-use/commit/760edf1))
+
+# [9.5.0](https://github.com/streamich/react-use/compare/v9.4.1...v9.5.0) (2019-06-16)
+
+
+### Bug Fixes
+
+* add missing `rate` property ([fb795a6](https://github.com/streamich/react-use/commit/fb795a6))
+
+
+### Features
+
+* add rate option in useSpeech ([f52f1f7](https://github.com/streamich/react-use/commit/f52f1f7))
+* add rate option in useSpeech ([#399](https://github.com/streamich/react-use/issues/399)) ([0e4ebc6](https://github.com/streamich/react-use/commit/0e4ebc6))
+
+## [9.4.1](https://github.com/streamich/react-use/compare/v9.4.0...v9.4.1) (2019-06-12)
+
+
+### Bug Fixes
+
+* fix Storybook docs Markdown import ([962a312](https://github.com/streamich/react-use/commit/962a312))
+
+# [9.4.0](https://github.com/streamich/react-use/compare/v9.3.0...v9.4.0) (2019-06-04)
+
+
+### Bug Fixes
+
+* fix TypeScript error ([72e3036](https://github.com/streamich/react-use/commit/72e3036))
+* **docs:** syntax error, improve examples ([8bbe9d8](https://github.com/streamich/react-use/commit/8bbe9d8))
+
+
+### Features
+
+* improve createReducer function ([6ba2d93](https://github.com/streamich/react-use/commit/6ba2d93)), closes [#164](https://github.com/streamich/react-use/issues/164)
+
+# [9.3.0](https://github.com/streamich/react-use/compare/v9.2.0...v9.3.0) (2019-05-31)
+
+
+### Features
+
+* improve useAsync and useAsyncFn ([3ab1d5d](https://github.com/streamich/react-use/commit/3ab1d5d))
+
+# [9.2.0](https://github.com/streamich/react-use/compare/v9.1.2...v9.2.0) (2019-05-31)
+
+
+### Features
+
+* 🎸 improve useObservable() type annotations ([d0c3713](https://github.com/streamich/react-use/commit/d0c3713))
+* improve useSetState() typings ([fad4440](https://github.com/streamich/react-use/commit/fad4440))
+
+## [9.1.2](https://github.com/streamich/react-use/compare/v9.1.1...v9.1.2) (2019-05-24)
+
+
+### Bug Fixes
+
+* **useAudio:** src change should reset isPlaying state ([65bffca](https://github.com/streamich/react-use/commit/65bffca))
+
+## [9.1.1](https://github.com/streamich/react-use/compare/v9.1.0...v9.1.1) (2019-05-24)
+
+
+### Bug Fixes
+
+* **useMap:** more stringent type ([7bbbe47](https://github.com/streamich/react-use/commit/7bbbe47))
+
+# [9.1.0](https://github.com/streamich/react-use/compare/v9.0.0...v9.1.0) (2019-05-24)
+
+
+### Features
+
+* pass arguments to useAsyncFn function ([6789d10](https://github.com/streamich/react-use/commit/6789d10))
+
+# [9.0.0](https://github.com/streamich/react-use/compare/v8.4.0...v9.0.0) (2019-05-09)
+
+
+### Features
+
+* improve useToggle interface ([81b1cac](https://github.com/streamich/react-use/commit/81b1cac))
+
+
+### BREAKING CHANGES
+
+* useToggle interface changed
+
+# [8.4.0](https://github.com/streamich/react-use/compare/v8.3.1...v8.4.0) (2019-05-07)
+
+
+### Features
+
+* add usePrevious hook ([4861a39](https://github.com/streamich/react-use/commit/4861a39))
+
+## [8.3.1](https://github.com/streamich/react-use/compare/v8.3.0...v8.3.1) (2019-04-29)
+
+
+### Bug Fixes
+
+* **useRefMounted:** only run and cleanup once ([6a651be](https://github.com/streamich/react-use/commit/6a651be))
+
+# [8.3.0](https://github.com/streamich/react-use/compare/v8.2.0...v8.3.0) (2019-04-29)
+
+
+### Features
+
+* add type define for createMemo ([6638c1a](https://github.com/streamich/react-use/commit/6638c1a))
+
+# [8.2.0](https://github.com/streamich/react-use/compare/v8.1.4...v8.2.0) (2019-04-23)
+
+
+### Bug Fixes
+
+* make options useGeolocation optional ([01959a1](https://github.com/streamich/react-use/commit/01959a1))
+
+
+### Features
+
+* support options for useGeolocation ([7d4c59e](https://github.com/streamich/react-use/commit/7d4c59e))
+
+## [8.1.4](https://github.com/streamich/react-use/compare/v8.1.3...v8.1.4) (2019-04-23)
+
+
+### Bug Fixes
+
+* 🐛 support click away on iOS, allow user to chose events ([f14e1d7](https://github.com/streamich/react-use/commit/f14e1d7))
+
+## [8.1.3](https://github.com/streamich/react-use/compare/v8.1.2...v8.1.3) (2019-04-18)
+
+
+### Bug Fixes
+
+* 🐛 don't fire typing event on modifier keys pressed ([ce76edf](https://github.com/streamich/react-use/commit/ce76edf))
+
+## [8.1.2](https://github.com/streamich/react-use/compare/v8.1.1...v8.1.2) (2019-04-12)
+
+
+### Bug Fixes
+
+* **useIdle:** include 'ms' prop in uesEffect dependencies ([7a670a2](https://github.com/streamich/react-use/commit/7a670a2))
+
+## [8.1.1](https://github.com/streamich/react-use/compare/v8.1.0...v8.1.1) (2019-04-09)
+
+
+### Bug Fixes
+
+* 🐛 make useLocation work on server, improve hook ([6f6030a](https://github.com/streamich/react-use/commit/6f6030a))
+
+# [8.1.0](https://github.com/streamich/react-use/compare/v8.0.0...v8.1.0) (2019-04-08)
+
+
+### Features
+
+* add useAsyncCallback hook ([c6ecb36](https://github.com/streamich/react-use/commit/c6ecb36))
+
+# [8.0.0](https://github.com/streamich/react-use/compare/v7.6.0...v8.0.0) (2019-04-08)
+
+
+### Features
+
+* change useCopyToClipboard implementation ([c391038](https://github.com/streamich/react-use/commit/c391038))
+
+
+### BREAKING CHANGES
+
+* useCopyToClipboard interface changed
+
+# [7.6.0](https://github.com/streamich/react-use/compare/v7.5.0...v7.6.0) (2019-04-07)
+
+
+### Bug Fixes
+
+* 🐛 handle case when activeElement is empty ([3d83705](https://github.com/streamich/react-use/commit/3d83705))
+
+
+### Features
+
+* 🎸 add useStartTypings hook ([5fda2e0](https://github.com/streamich/react-use/commit/5fda2e0))
+
+# [7.5.0](https://github.com/streamich/react-use/compare/v7.4.0...v7.5.0) (2019-04-07)
+
+
+### Features
+
+* 🎸 add onCopy and onError events and use NPM copy library ([2553225](https://github.com/streamich/react-use/commit/2553225))
+* 🎸 improve useCopyToClipboard() hook ([f185044](https://github.com/streamich/react-use/commit/f185044))
+* 🎸 make useCopyToClipboard hook interface more idiomatic ([0a6d773](https://github.com/streamich/react-use/commit/0a6d773))
+* add useCopyToClipboard() hook ([4d8e276](https://github.com/streamich/react-use/commit/4d8e276))
+
+# [7.4.0](https://github.com/streamich/react-use/compare/v7.3.1...v7.4.0) (2019-04-07)
+
+
+### Features
+
+* add useDeepCompareEffect hook ([77e015b](https://github.com/streamich/react-use/commit/77e015b))
+
+## [7.3.1](https://github.com/streamich/react-use/compare/v7.3.0...v7.3.1) (2019-03-31)
+
+
+### Bug Fixes
+
+* 🐛 call key{up/donw} callbacks in useKeyPressEvent correct ([60064a6](https://github.com/streamich/react-use/commit/60064a6))
+
+# [7.3.0](https://github.com/streamich/react-use/compare/v7.2.0...v7.3.0) (2019-03-31)
+
+
+### Features
+
+* add useEffectOnce hook ([06c12d4](https://github.com/streamich/react-use/commit/06c12d4))
+
+# [7.2.0](https://github.com/streamich/react-use/compare/v7.1.1...v7.2.0) (2019-03-31)
+
+
+### Features
+
+* default dependency array for useAsync and useAsyncRetry ([cb140a0](https://github.com/streamich/react-use/commit/cb140a0))
+
+## [7.1.1](https://github.com/streamich/react-use/compare/v7.1.0...v7.1.1) (2019-03-30)
+
+
+### Bug Fixes
+
+* consistent refs in useFullscreen hook ([dc85499](https://github.com/streamich/react-use/commit/dc85499))
+
+# [7.1.0](https://github.com/streamich/react-use/compare/v7.0.2...v7.1.0) (2019-03-29)
+
+
+### Bug Fixes
+
+* useClickAway TypeScript typings ([4b20083](https://github.com/streamich/react-use/commit/4b20083))
+
+
+### Features
+
+* pass click event in useClickAway to user ([01e38bc](https://github.com/streamich/react-use/commit/01e38bc))
+
+## [7.0.2](https://github.com/streamich/react-use/compare/v7.0.1...v7.0.2) (2019-03-29)
+
+
+### Bug Fixes
+
+* 🐛 add rebound and keyboards deps back to peerDependencies ([4fc46aa](https://github.com/streamich/react-use/commit/4fc46aa))
+
+## [7.0.1](https://github.com/streamich/react-use/compare/v7.0.0...v7.0.1) (2019-03-29)
+
+
+### Bug Fixes
+
+* add optional attributes in AsyncState ([b0c9770](https://github.com/streamich/react-use/commit/b0c9770))
+
+# [7.0.0](https://github.com/streamich/react-use/compare/v6.2.2...v7.0.0) (2019-03-28)
+
+
+### Bug Fixes
+
+* 🐛 fix TypeScript build errors ([5c95f28](https://github.com/streamich/react-use/commit/5c95f28))
+* 🐛 make sure all paths in usePageLeave return ([6655092](https://github.com/streamich/react-use/commit/6655092))
+* 🐛 track "over" state better in useDrop hook ([acc355c](https://github.com/streamich/react-use/commit/acc355c))
+
+
+### Features
+
+* 🎸 add clear() to useList, use fn for state updates ([b20cf7c](https://github.com/streamich/react-use/commit/b20cf7c))
+* 🎸 add createRenderProp function for creating render-props ([f4fd748](https://github.com/streamich/react-use/commit/f4fd748))
+* 🎸 add useDrop hook ([6e415cf](https://github.com/streamich/react-use/commit/6e415cf))
+* 🎸 add useDropArea hook ([676d0de](https://github.com/streamich/react-use/commit/676d0de))
+* 🎸 add useEvent hook ([2a13cfb](https://github.com/streamich/react-use/commit/2a13cfb))
+* 🎸 add useKey hook ([299fd86](https://github.com/streamich/react-use/commit/299fd86))
+* 🎸 add useKeyboardJs hook ([3516aa6](https://github.com/streamich/react-use/commit/3516aa6))
+* 🎸 add usePageLeave hook ([33ac91b](https://github.com/streamich/react-use/commit/33ac91b))
+* 🎸 add useThrottleFn hook that throttles function ([0ccdf95](https://github.com/streamich/react-use/commit/0ccdf95))
+* 🎸 improve useFullscreen hook ([7c38165](https://github.com/streamich/react-use/commit/7c38165))
+* 🎸 keep keyboard events in useKeyPress hook ([00fecab](https://github.com/streamich/react-use/commit/00fecab))
+* 🎸 refactor useKeyPressEvent hook ([c0658f6](https://github.com/streamich/react-use/commit/c0658f6))
+* 🎸 return events from useKeyboardJs hook ([aa277b8](https://github.com/streamich/react-use/commit/aa277b8))
+* 🎸 simplify and improve useThrottle hook ([452e8d9](https://github.com/streamich/react-use/commit/452e8d9))
+* 🎸 useKeyPress hook now uses useKey, KeyboardJS removed ([727743b](https://github.com/streamich/react-use/commit/727743b))
+
+
+### BREAKING CHANGES
+
+* 🧨 useKeyPressEvent hook modified for dependency injection and providing
+event objects to user
+* 🧨 KeyboardJS now available anymore in useKeyPress hook, instead it will be
+a separate useKeyPressKJ hook.
+* 🧨 useThrottle is now a completely different hook
+
+## [6.2.2](https://github.com/streamich/react-use/compare/v6.2.1...v6.2.2) (2019-03-28)
+
+
+### Bug Fixes
+
+* fix deps arg and union type in useAsync and useAsyncRetry ([929e726](https://github.com/streamich/react-use/commit/929e726))
+
+## [6.2.1](https://github.com/streamich/react-use/compare/v6.2.0...v6.2.1) (2019-03-27)
+
+
+### Bug Fixes
+
+* set 'module' field properly ([35d4fc2](https://github.com/streamich/react-use/commit/35d4fc2))
+
+# [6.2.0](https://github.com/streamich/react-use/compare/v6.1.0...v6.2.0) (2019-03-27)
+
+
+### Bug Fixes
+
+* add esm to 'files' in package.json ([fc1ba07](https://github.com/streamich/react-use/commit/fc1ba07))
+* clean esm folder as well ([0a10a6e](https://github.com/streamich/react-use/commit/0a10a6e))
+
+
+### Features
+
+* emit code in ES Module mode ([464642e](https://github.com/streamich/react-use/commit/464642e))
+
+# [6.1.0](https://github.com/streamich/react-use/compare/v6.0.0...v6.1.0) (2019-03-26)
+
+
+### Features
+
+* add useThrottle hook ([756bc99](https://github.com/streamich/react-use/commit/756bc99))
+
+# [6.0.0](https://github.com/streamich/react-use/compare/v5.16.1...v6.0.0) (2019-03-26)
+
+
+### Bug Fixes
+
+* 🐛 bump nano-css ([f1f36dc](https://github.com/streamich/react-use/commit/f1f36dc)), closes [#90](https://github.com/streamich/react-use/issues/90)
+* 🐛 don't throw only in development ([f5faba5](https://github.com/streamich/react-use/commit/f5faba5))
+
+
+### chore
+
+* 🤖 don't install only large dependencies ([6170067](https://github.com/streamich/react-use/commit/6170067))
+
+
+### Features
+
+* 🎸 add {bound} option to useMouse ([9bb02a1](https://github.com/streamich/react-use/commit/9bb02a1))
+* 🎸 implement useClickAway, remove useOutsideClick ([a03143a](https://github.com/streamich/react-use/commit/a03143a))
+* 🎸 keep global state of all useLockBodyScroll hooks ([5dd10e9](https://github.com/streamich/react-use/commit/5dd10e9))
+* 🎸 move extra mouse functionality into useMouseHovered ([8b0580e](https://github.com/streamich/react-use/commit/8b0580e))
+* more precise size for useMouse ([b887075](https://github.com/streamich/react-use/commit/b887075))
+
+
+### BREAKING CHANGES
+
+* 🧨 error is logged instead of thrown in development environment
+* 🧨 useOutsideClick is now useClickAway
+* 🧨 useCallbag hook is removed, some hooks KeyboardJS and Rebound installed
+separately
+
+## [5.16.1](https://github.com/streamich/react-use/compare/v5.16.0...v5.16.1) (2019-03-26)
+
+
+### Bug Fixes
+
+* types for useGeolocation ([b72c098](https://github.com/streamich/react-use/commit/b72c098))
+
+# [5.16.0](https://github.com/streamich/react-use/compare/v5.15.0...v5.16.0) (2019-03-25)
+
+
+### Features
+
+* more precise size for useMouse ([1761031](https://github.com/streamich/react-use/commit/1761031))
+
+# [5.15.0](https://github.com/streamich/react-use/compare/v5.14.0...v5.15.0) (2019-03-25)
+
+
+### Features
+
+* add useMouse hook ([17dfa8e](https://github.com/streamich/react-use/commit/17dfa8e))
+
+# [5.14.0](https://github.com/streamich/react-use/compare/v5.13.0...v5.14.0) (2019-03-24)
+
+
+### Features
+
+* 🎸 keep global state of all useLockBodyScroll hooks ([9bb7047](https://github.com/streamich/react-use/commit/9bb7047))
+* add useLockBodyScroll hook ([d990db4](https://github.com/streamich/react-use/commit/d990db4))
+
+# [5.13.0](https://github.com/streamich/react-use/compare/v5.12.1...v5.13.0) (2019-03-23)
+
+
+### Features
+
+* add useScroll hook ([a92e9b2](https://github.com/streamich/react-use/commit/a92e9b2))
+
+## [5.12.1](https://github.com/streamich/react-use/compare/v5.12.0...v5.12.1) (2019-03-23)
+
+
+### Bug Fixes
+
+* 🐛 cancel animation frame on un-mount in useWindowScroll() ([bc021ce](https://github.com/streamich/react-use/commit/bc021ce))
+
+# [5.12.0](https://github.com/streamich/react-use/compare/v5.11.0...v5.12.0) (2019-03-23)
+
+
+### Features
+
+* add useWindowScroll hook ([076d0de](https://github.com/streamich/react-use/commit/076d0de))
+
+# [5.11.0](https://github.com/streamich/react-use/compare/v5.10.0...v5.11.0) (2019-03-22)
+
+
+### Features
+
+* 🎸 refresh useCss hook ([0116cc9](https://github.com/streamich/react-use/commit/0116cc9))
+
+# [5.10.0](https://github.com/streamich/react-use/compare/v5.9.0...v5.10.0) (2019-03-21)
+
+
+### Features
+
+* add useUpdateEffect hook ([c2afd23](https://github.com/streamich/react-use/commit/c2afd23))
+
+# [5.9.0](https://github.com/streamich/react-use/compare/v5.8.1...v5.9.0) (2019-03-21)
+
+
+### Features
+
+* add useAsyncRetry hook ([576cf42](https://github.com/streamich/react-use/commit/576cf42))
+
+
+### Performance Improvements
+
+* remove asyn/await wrapper ([8e3de1c](https://github.com/streamich/react-use/commit/8e3de1c))
+
+## [5.8.1](https://github.com/streamich/react-use/compare/v5.8.0...v5.8.1) (2019-03-20)
+
+
+### Bug Fixes
+
+* 🐛 use useLayoutEffect() in useCss() to inject CSS quick ([7328f26](https://github.com/streamich/react-use/commit/7328f26))
+
+# [5.8.0](https://github.com/streamich/react-use/compare/v5.7.1...v5.8.0) (2019-03-19)
+
+
+### Features
+
+* release useKeyPressEvent() ([96798e2](https://github.com/streamich/react-use/commit/96798e2))
+
+## [5.7.1](https://github.com/streamich/react-use/compare/v5.7.0...v5.7.1) (2019-03-15)
+
+
+### Bug Fixes
+
+* 🐛 allow every promise in usePromise() hook have own type ([d60fef7](https://github.com/streamich/react-use/commit/d60fef7))
+
+# [5.7.0](https://github.com/streamich/react-use/compare/v5.6.0...v5.7.0) (2019-03-15)
+
+
+### Bug Fixes
+
+* 🐛 fix TypeScript typings for usePromise() ([ba0acb6](https://github.com/streamich/react-use/commit/ba0acb6))
+
+
+### Features
+
+* 🎸 add usePromise() hook ([aad368b](https://github.com/streamich/react-use/commit/aad368b))
+
+# [5.6.0](https://github.com/streamich/react-use/compare/v5.5.6...v5.6.0) (2019-03-13)
+
+
+### Features
+
+* transpile down to ES5 ([61382e3](https://github.com/streamich/react-use/commit/61382e3))
+
+## [5.5.6](https://github.com/streamich/react-use/compare/v5.5.5...v5.5.6) (2019-03-11)
+
+
+### Bug Fixes
+
+* correct createMemo.md ([4e2d639](https://github.com/streamich/react-use/commit/4e2d639))
+* correct createMemo.story ([9c8e093](https://github.com/streamich/react-use/commit/9c8e093))
+
+## [5.5.5](https://github.com/streamich/react-use/compare/v5.5.4...v5.5.5) (2019-03-04)
+
+
+### Bug Fixes
+
+* 🐛 make useWindowSize work on server ([8f93853](https://github.com/streamich/react-use/commit/8f93853))
+
+## [5.5.4](https://github.com/streamich/react-use/compare/v5.5.3...v5.5.4) (2019-02-25)
+
+
+### Bug Fixes
+
+* 🐛 new React behaviour needs useState to set something ([e926faf](https://github.com/streamich/react-use/commit/e926faf)), closes [#128](https://github.com/streamich/react-use/issues/128)
+
+## [5.5.3](https://github.com/streamich/react-use/compare/v5.5.2...v5.5.3) (2019-02-25)
+
+
+### Bug Fixes
+
+* **deps:** update dependency use-callbag to ^0.2.0 ([4d49d0b](https://github.com/streamich/react-use/commit/4d49d0b))
+
+## [5.5.2](https://github.com/streamich/react-use/compare/v5.5.1...v5.5.2) (2019-02-24)
+
+
+### Bug Fixes
+
+* **deps:** update dependency use-onclickoutside to ^0.3.0 ([0baae6d](https://github.com/streamich/react-use/commit/0baae6d))
+
+## [5.5.1](https://github.com/streamich/react-use/compare/v5.5.0...v5.5.1) (2019-02-24)
+
+
+### Bug Fixes
+
+* **deps:** update dependency ts-easing to ^0.2.0 ([3321e11](https://github.com/streamich/react-use/commit/3321e11))
+
+# [5.5.0](https://github.com/streamich/react-use/compare/v5.4.1...v5.5.0) (2019-02-23)
+
+
+### Bug Fixes
+
+* add type definition for useList() remove() method ([ea2dc43](https://github.com/streamich/react-use/commit/ea2dc43))
+* useSetState bug ([83611a1](https://github.com/streamich/react-use/commit/83611a1))
+
+
+### Features
+
+* Add remove method for useList ([5a295d9](https://github.com/streamich/react-use/commit/5a295d9))
+
## [5.4.1](https://github.com/streamich/react-use/compare/v5.4.0...v5.4.1) (2019-02-19)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 0000000000..67c03a54ea
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,62 @@
+# Contributing
+
+Thanks for being willing to contribute 🙌 If you contribute to this project, you agree to release your work under the license of this project.
+
+**Working on your first Pull Request?** You can learn how from this [First Contributions](https://github.com/firstcontributions/first-contributions) guide.
+
+## Project setup
+
+1. Fork and clone the repo
+1. Run `yarn install` to install dependencies
+1. Create a branch for your PR with `git checkout -b pr/your-branch-name`
+
+> Tip: Keep your `master` branch pointing at the original repository and make
+> pull requests from branches on your fork. To do this, run:
+>
+> ```sh
+> git remote add upstream https://github.com/streamich/react-use.git
+> git fetch upstream
+> git branch --set-upstream-to=upstream/master master
+> ```
+>
+> This will add the original repository as a "remote" called "upstream," Then
+> fetch the git information from that remote, then set your local `master`
+> branch to use the upstream master branch whenever you run `git pull`. Then you
+> can make all of your pull request branches based on this `master` branch.
+> Whenever you want to update your version of `master`, do a regular `git pull`.
+
+## Development
+
+This library is a collection of React hooks so a proposal for a new hook will need to utilize the [React Hooks API](https://reactjs.org/docs/hooks-reference.html) internally to be taken into consideration.
+
+### Creating a new hook
+
+1. Create `src/useYourHookName.ts` and `stories/useYourHookName.story.tsx`, run `yarn start` to start the storybook development server and start coding your hook
+1. Create `tests/useYourHookName.test.ts`, run `yarn test:watch` to start the test runner in watch mode and start writing tests for your hook
+1. Create `docs/useYourHookName.md` and create documentation for your hook
+1. Export your hook from `src/index.ts` and add your hook to `README.md`
+
+You can also write your tests first if you prefer [test-driven development](https://en.wikipedia.org/wiki/Test-driven_development).
+
+### Updating an existing hook
+
+1. Run `yarn start` to start the storybook development server and start applying changes
+2. Update tests according to your changes using `yarn test:watch`
+3. Update documentation according to your changes
+
+## Committing and Pushing changes
+
+### Commit messages
+
+This repo uses [semantic-release](https://github.com/semantic-release/semantic-release) and [conventional commit messages](https://conventionalcommits.org) so prefix your commits with `fix:` or `feat:` if you want your changes to appear in [release notes](https://github.com/streamich/react-use/blob/master/CHANGELOG.md).
+
+### Git hooks
+
+There are git hooks set up with this project that are automatically enabled
+when you install dependencies. These hooks automatically test and validate your code when creating commits. They're really handy but can be temporarily disabled by adding a `--no-verify` flag to your commit command. This is useful when you want to commit and push to get feedback on uncompleted code.
+
+## Help needed
+
+Please have a look at the [open issues](https://github.com/streamich/react-use/issues) and respond to questions, bug reports and feature requests. Thanks!
+
+We're also looking to improve the code coverage on this project. To easily know what hooks need tests run `yarn test:coverage` to generate a code coverage report. You can see the report in your terminal or open `coverage/lcov-report/index.html` to see the HTML report.
diff --git a/README.md b/README.md
index 3d8e0dc588..cc1728fafd 100644
--- a/README.md
+++ b/README.md
@@ -13,10 +13,23 @@
+
+
+
+
+
+
+
+
+
+
+
+
Collection of essential React Hooks.
+ Port of libreact.
- Port of libreact. See demos.
+ Translations: 🇨🇳 汉语
@@ -32,90 +45,155 @@
- [**Sensors**](./docs/Sensors.md)
- [`useBattery`](./docs/useBattery.md) — tracks device battery state. [![][img-demo]](https://codesandbox.io/s/qlvn662zww)
- - [`useGeolocation`](./docs/useGeolocation.md) — tracks geo location state of user's device.
+ - [`useGeolocation`](./docs/useGeolocation.md) — tracks geo location state of user's device. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/sensors-usegeolocation--demo)
- [`useHover` and `useHoverDirty`](./docs/useHover.md) — tracks mouse hover state of some element. [![][img-demo]](https://codesandbox.io/s/zpn583rvx)
+ - [`useHash`](./docs/useHash.md) — tracks location hash value. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/sensors-usehash--demo)
- [`useIdle`](./docs/useIdle.md) — tracks whether user is being inactive.
- - [`useKeyPress`](./docs/useKeyPress.md) — tracks whether a keyboard key—or set of keys—was pressed.
- - [`useLocation`](./docs/useLocation.md) — tracks page navigation bar location state.
- - [`useMedia`](./docs/useMedia.md) — tracks state of a CSS media query.
+ - [`useIntersection`](./docs/useIntersection.md) — tracks an HTML element's intersection. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/sensors-useintersection--demo)
+ - [`useKey`](./docs/useKey.md), [`useKeyPress`](./docs/useKeyPress.md), [`useKeyboardJs`](./docs/useKeyboardJs.md), and [`useKeyPressEvent`](./docs/useKeyPressEvent.md) — track keys. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/sensors-usekeypressevent--demo)
+ - [`useLocation`](./docs/useLocation.md) and [`useSearchParam`](./docs/useSearchParam.md) — tracks page navigation bar location state.
+ - [`useLongPress`](./docs/useLongPress.md) — tracks long press gesture of some element.
+ - [`useMedia`](./docs/useMedia.md) — tracks state of a CSS media query. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/sensors-usemedia--demo)
- [`useMediaDevices`](./docs/useMediaDevices.md) — tracks state of connected hardware devices.
- [`useMotion`](./docs/useMotion.md) — tracks state of device's motion sensor.
- - [`useNetwork`](./docs/useNetwork.md) — tracks state of user's internet connection.
+ - [`useMouse` and `useMouseHovered`](./docs/useMouse.md) — tracks state of mouse position. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/sensors-usemouse--docs)
+ - [`useMouseWheel`](./docs/useMouseWheel.md) — tracks deltaY of scrolled mouse wheel. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/sensors-usemousewheel--docs)
+ - [`useNetworkState`](./docs/useNetworkState.md) — tracks the state of browser's network connection. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/sensors-usenetworkstate--demo)
- [`useOrientation`](./docs/useOrientation.md) — tracks state of device's screen orientation.
- - [`useSize`](./docs/useSize.md) — tracks some HTML element's dimensions.
+ - [`usePageLeave`](./docs/usePageLeave.md) — triggers when mouse leaves page boundaries.
+ - [`useScratch`](./docs/useScratch.md) — tracks mouse click-and-scrub state.
+ - [`useScroll`](./docs/useScroll.md) — tracks an HTML element's scroll position. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/sensors-usescroll--docs)
+ - [`useScrolling`](./docs/useScrolling.md) — tracks whether HTML element is scrolling.
+ - [`useStartTyping`](./docs/useStartTyping.md) — detects when user starts typing.
+ - [`useWindowScroll`](./docs/useWindowScroll.md) — tracks `Window` scroll position. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/sensors-usewindowscroll--docs)
- [`useWindowSize`](./docs/useWindowSize.md) — tracks `Window` dimensions. [![][img-demo]](https://codesandbox.io/s/m7ln22668)
+ - [`useMeasure`](./docs/useMeasure.md) and [`useSize`](./docs/useSize.md) — tracks an HTML element's dimensions. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/sensors-usemeasure--demo)
+ - [`createBreakpoint`](./docs/createBreakpoint.md) — tracks `innerWidth`
+ - [`useScrollbarWidth`](./docs/useScrollbarWidth.md) — detects browser's native scrollbars width. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/sensors-usescrollbarwidth--demo)
+ - [`usePinchZoom`](./docs/usePinchZoom.md) — tracks pointer events to detect pinch zoom in and out status. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/sensors-usePinchZoom--demo)
- [**UI**](./docs/UI.md)
- [`useAudio`](./docs/useAudio.md) — plays audio and exposes its controls. [![][img-demo]](https://codesandbox.io/s/2o4lo6rqy)
- - [`useOutsideClick`](./docs/useOutsideClick.md) — triggers callback when user clicks outside target area.
+ - [`useClickAway`](./docs/useClickAway.md) — triggers callback when user clicks outside target area.
+ - [`useCss`](./docs/useCss.md) — dynamically adjusts CSS.
+ - [`useDrop` and `useDropArea`](./docs/useDrop.md) — tracks file, link and copy-paste drops.
+ - [`useFullscreen`](./docs/useFullscreen.md) — display an element or video full-screen. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/ui-usefullscreen--demo)
+ - [`useSlider`](./docs/useSlider.md) — provides slide behavior over any HTML element. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/ui-useslider--demo)
- [`useSpeech`](./docs/useSpeech.md) — synthesizes speech from a text string. [![][img-demo]](https://codesandbox.io/s/n090mqz69m)
- - [`useVideo`](./docs/useVideo.md) — plays video, tracks its state, and exposes playback controls.
- - [`useWait`](./docs/useWait.md) — complex waiting management for UIs.
+ - [`useVibrate`](./docs/useVibrate.md) — provide physical feedback using the [Vibration API](https://developer.mozilla.org/en-US/docs/Web/API/Vibration_API). [![][img-demo]](https://streamich.github.io/react-use/?path=/story/ui-usevibrate--demo)
+ - [`useVideo`](./docs/useVideo.md) — plays video, tracks its state, and exposes playback controls. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/ui-usevideo--demo)
- [**Animations**](./docs/Animations.md)
- [`useRaf`](./docs/useRaf.md) — re-renders component on each `requestAnimationFrame`.
+ - [`useInterval`](./docs/useInterval.md) and [`useHarmonicIntervalFn`](./docs/useHarmonicIntervalFn.md) — re-renders component on a set interval using `setInterval`.
- [`useSpring`](./docs/useSpring.md) — interpolates number over time according to spring dynamics.
- - [`useTimeout`](./docs/useTimeout.md) — returns true after a timeout.
+ - [`useTimeout`](./docs/useTimeout.md) — re-renders component after a timeout.
+ - [`useTimeoutFn`](./docs/useTimeoutFn.md) — calls given function after a timeout. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/animation-usetimeoutfn--demo)
- [`useTween`](./docs/useTween.md) — re-renders component, while tweening a number from 0 to 1. [![][img-demo]](https://codesandbox.io/s/52990wwzyl)
- [`useUpdate`](./docs/useUpdate.md) — returns a callback, which re-renders component when called.
- [**Side-effects**](./docs/Side-effects.md)
- - [`useAsync`](./docs/useAsync.md) — resolves an `async` function.
- - [`useCss`](./docs/useCss.md) — dynamically adjusts CSS.
+ - [`useAsync`](./docs/useAsync.md), [`useAsyncFn`](./docs/useAsyncFn.md), and [`useAsyncRetry`](./docs/useAsyncRetry.md) — resolves an `async` function.
+ - [`useBeforeUnload`](./docs/useBeforeUnload.md) — shows browser alert when user try to reload or close the page.
+ - [`useCookie`](./docs/useCookie.md) — provides way to read, update and delete a cookie. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/side-effects-usecookie--demo)
+ - [`useCopyToClipboard`](./docs/useCopyToClipboard.md) — copies text to clipboard.
+ - [`useDebounce`](./docs/useDebounce.md) — debounces a function. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/side-effects-usedebounce--demo)
+ - [`useError`](./docs/useError.md) — error dispatcher. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/side-effects-useerror--demo)
- [`useFavicon`](./docs/useFavicon.md) — sets favicon of the page.
- [`useLocalStorage`](./docs/useLocalStorage.md) — manages a value in `localStorage`.
+ - [`useLockBodyScroll`](./docs/useLockBodyScroll.md) — lock scrolling of the body element.
+ - [`useRafLoop`](./docs/useRafLoop.md) — calls given function inside the RAF loop.
- [`useSessionStorage`](./docs/useSessionStorage.md) — manages a value in `sessionStorage`.
+ - [`useThrottle` and `useThrottleFn`](./docs/useThrottle.md) — throttles a function. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/side-effects-usethrottle--demo)
- [`useTitle`](./docs/useTitle.md) — sets title of the page.
- - [`useDebounce`](./docs/useDebounce.md) — debounces a function.
+ - [`usePermission`](./docs/usePermission.md) — query permission status for browser APIs.
- [**Lifecycles**](./docs/Lifecycles.md)
+ - [`useEffectOnce`](./docs/useEffectOnce.md) — a modified [`useEffect`](https://reactjs.org/docs/hooks-reference.html#useeffect) hook that only runs once.
+ - [`useEvent`](./docs/useEvent.md) — subscribe to events.
- [`useLifecycles`](./docs/useLifecycles.md) — calls `mount` and `unmount` callbacks.
- - [`useRefMounted`](./docs/useRefMounted.md) — tracks if component is mounted.
+ - [`useMountedState`](./docs/useMountedState.md) and [`useUnmountPromise`](./docs/useUnmountPromise.md) — track if component is mounted.
+ - [`usePromise`](./docs/usePromise.md) — resolves promise only while component is mounted.
- [`useLogger`](./docs/useLogger.md) — logs in console as component goes through life-cycles.
- [`useMount`](./docs/useMount.md) — calls `mount` callbacks.
- [`useUnmount`](./docs/useUnmount.md) — calls `unmount` callbacks.
+ - [`useUpdateEffect`](./docs/useUpdateEffect.md) — run an `effect` only on updates.
+ - [`useIsomorphicLayoutEffect`](./docs/useIsomorphicLayoutEffect.md) — `useLayoutEffect` that that works on server.
+ - [`useDeepCompareEffect`](./docs/useDeepCompareEffect.md), [`useShallowCompareEffect`](./docs/useShallowCompareEffect.md), and [`useCustomCompareEffect`](./docs/useCustomCompareEffect.md)
- [**State**](./docs/State.md)
- [`createMemo`](./docs/createMemo.md) — factory of memoized hooks.
- - [`useCallbag`](./docs/useCallbag.md) — tracks latest value of a callbag.
+ - [`createReducer`](./docs/createReducer.md) — factory of reducer hooks with custom middleware.
+ - [`createReducerContext`](./docs/createReducerContext.md) and [`createStateContext`](./docs/createStateContext.md) — factory of hooks for a sharing state between components.
+ - [`useDefault`](./docs/useDefault.md) — returns the default value when state is `null` or `undefined`.
- [`useGetSet`](./docs/useGetSet.md) — returns state getter `get()` instead of raw state.
- [`useGetSetState`](./docs/useGetSetState.md) — as if [`useGetSet`](./docs/useGetSet.md) and [`useSetState`](./docs/useSetState.md) had a baby.
+ - [`useLatest`](./docs/useLatest.md) — returns the latest state or props
+ - [`usePrevious`](./docs/usePrevious.md) — returns the previous state or props. [![][img-demo]](https://codesandbox.io/s/fervent-galileo-krgx6)
+ - [`usePreviousDistinct`](./docs/usePreviousDistinct.md) — like `usePrevious` but with a predicate to determine if `previous` should update.
- [`useObservable`](./docs/useObservable.md) — tracks latest value of an `Observable`.
+ - [`useRafState`](./docs/useRafState.md) — creates `setState` method which only updates after `requestAnimationFrame`. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/state-userafstate--demo)
- [`useSetState`](./docs/useSetState.md) — creates `setState` method which works like `this.setState`. [![][img-demo]](https://codesandbox.io/s/n75zqn1xp0)
- - [`useToggle` and `useBoolean`](./docs/useToggle.md) — tracks state of a boolean.
- - [`useCounter` and `useNumber`](./docs/useCounter.md) — tracks state of a number.
- - [`useList`](./docs/useList.md) — tracks state of an array.
- - [`useMap`](./docs/useMap.md) — tracks state of an object.
+ - [`useStateList`](./docs/useStateList.md) — circularly iterates over an array. [![][img-demo]](https://codesandbox.io/s/bold-dewdney-pjzkd)
+ - [`useToggle` and `useBoolean`](./docs/useToggle.md) — tracks state of a boolean. [![][img-demo]](https://codesandbox.io/s/focused-sammet-brw2d)
+ - [`useCounter` and `useNumber`](./docs/useCounter.md) — tracks state of a number. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/state-usecounter--demo)
+ - [`useList`](./docs/useList.md) ~and [`useUpsert`](./docs/useUpsert.md)~ — tracks state of an array. [![][img-demo]](https://codesandbox.io/s/wonderful-mahavira-1sm0w)
+ - [`useMap`](./docs/useMap.md) — tracks state of an object. [![][img-demo]](https://codesandbox.io/s/quirky-dewdney-gi161)
+ - [`useSet`](./docs/useSet.md) — tracks state of a Set. [![][img-demo]](https://codesandbox.io/s/bold-shtern-6jlgw)
+ - [`useQueue`](./docs/useQueue.md) — implements simple queue.
+ - [`useStateValidator`](./docs/useStateValidator.md) — tracks state of an object. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/state-usestatevalidator--demo)
+ - [`useStateWithHistory`](./docs/useStateWithHistory.md) — stores previous state values and provides handles to travel through them. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/state-usestatewithhistory--demo)
+ - [`useMultiStateValidator`](./docs/useMultiStateValidator.md) — alike the `useStateValidator`, but tracks multiple states at a time. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/state-usemultistatevalidator--demo)
+ - [`useMediatedState`](./docs/useMediatedState.md) — like the regular `useState` but with mediation by custom function. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/state-usemediatedstate--demo)
+ - [`useFirstMountState`](./docs/useFirstMountState.md) — check if current render is first. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/state-usefirstmountstate--demo)
+ - [`useRendersCount`](./docs/useRendersCount.md) — count component renders. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/state-userenderscount--demo)
+ - [`createGlobalState`](./docs/createGlobalState.md) — cross component shared state.[![][img-demo]](https://streamich.github.io/react-use/?path=/story/state-createglobalstate--demo)
+ - [`useMethods`](./docs/useMethods.md) — neat alternative to `useReducer`. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/state-usemethods--demo)
+- [**Miscellaneous**]()
+ - [`useEnsuredForwardedRef`](./docs/useEnsuredForwardedRef.md) and [`ensuredForwardRef`](./docs/useEnsuredForwardedRef.md) — use a React.forwardedRef safely. [![][img-demo]](https://streamich.github.io/react-use/?path=/story/state-useensuredforwardedref--demo)
-
-
-You need to have React 16.8.1 or later installed to use Hooks API.
+ Usage — how to import.
+
+ Unlicense — public domain.
+
+ Support — add yourself to backer list below.
-You can import each hook individually import useToggle from 'react-use/lib/useToggle'.
-
- Unlicense — public domain. -
+{value}
+{value}
+count: {state.count}
+ + + + ++ Component A + + {count} + +
+ ); +}; + +const ComponentB = () => { + const [count, dispatch] = useSharedCounter(); + return ( ++ Component B + + {count} + +
+ ); +}; + +const Demo = () => { + return ( +Those two counters share the same value.
+
+ Component A:
+
+ setText(ev.target.value)} />
+
+ Component B:
+
+ setText(ev.target.value)} />
+
Those two fields share the same value.
+
- {JSON.stringify(state, null, 2)}
-
+ Try to reload or close tab
} + +Try to reload or close tab
} + +Value: {value}
+ +Unable to copy value: {state.error.message}
+ : state.value &&Copied {state.value}
} +useCustomCompareEffect with deep comparison: {count}
+useDeepCompareEffect: {count}
+
+ Press some keys on your keyboard, r key resets the list
+
+ {JSON.stringify(list, null, 4)}
+
+ {window.location.href}
+ Q W E R T Y
- {!hasPressedWord && (
-
+ Try pressing [, ], and r to
+ see the count incremented and decremented.
Count: {count}
+You clicked {count} times
+ + +{JSON.stringify(list, null, 2)}
{JSON.stringify(map, null, 2)}
-
-
Count: {state.count}
+ + + > + ); +}; +``` + +## Reference + +```js +const [state, methods] = useMethods(createMethods, initialState); +``` + +- `createMethods` — function that takes current state and return an object containing methods that return updated state. +- `initialState` — initial value of the state. diff --git a/docs/useMount.md b/docs/useMount.md index 52f37b85aa..14b4b4a3bc 100644 --- a/docs/useMount.md +++ b/docs/useMount.md @@ -1,8 +1,6 @@ # `useMount` -React lifecycle hook that call `mount` callback, when -component is mounted. - +React lifecycle hook that calls a function after the component is mounted. Use `useLifecycles` if you need both a mount and unmount function. ## Usage @@ -10,14 +8,13 @@ component is mounted. import {useMount} from 'react-use'; const Demo = () => { - useMount(() => console.log('MOUNTED')); + useMount(() => alert('MOUNTED')); return null; }; ``` - ## Reference -```js -useMount(mount); +```ts +useMount(fn: () => void); ``` diff --git a/docs/useMountedState.md b/docs/useMountedState.md new file mode 100644 index 0000000000..95fb7a6928 --- /dev/null +++ b/docs/useMountedState.md @@ -0,0 +1,28 @@ +# `useMountedState` + +> **NOTE!:** despite having `State` in its name **_this hook does not cause component re-render_**. +> This component designed to be used to avoid state updates on unmounted components. + +Lifecycle hook providing ability to check component's mount state. +Returns a function that will return `true` if component mounted and `false` otherwise. + +## Usage + +```jsx +import * as React from 'react'; +import {useMountedState} from 'react-use'; + +const Demo = () => { + const isMounted = useMountedState(); + + React.useEffect(() => { + setTimeout(() => { + if (isMounted()) { + // ... + } else { + // ... + } + }, 1000); + }); +}; +``` diff --git a/docs/useMouse.md b/docs/useMouse.md new file mode 100644 index 0000000000..795517e8a0 --- /dev/null +++ b/docs/useMouse.md @@ -0,0 +1,34 @@ +# `useMouse` and `useMouseHovered` + +React sensor hooks that re-render on mouse position changes. `useMouse` simply tracks +mouse position; `useMouseHovered` allows you to specify extra options: + +- `bound` — to bind mouse coordinates within the element +- `whenHovered` — whether to attach `mousemove` event handler only when user hovers over the element + +## Usage + +```jsx +import {useMouse} from 'react-use'; + +const Demo = () => { + const ref = React.useRef(null); + const {docX, docY, posX, posY, elX, elY, elW, elH} = useMouse(ref); + + return ( +
- {JSON.stringify(state, null, 2)}
-
- );
-};
-```
diff --git a/docs/useNetworkState.md b/docs/useNetworkState.md
new file mode 100644
index 0000000000..d05dfd2368
--- /dev/null
+++ b/docs/useNetworkState.md
@@ -0,0 +1,77 @@
+# `useNetworkState`
+
+Tracks the state of browser's network connection.
+
+As of the standard it is not guaranteed that browser connected to the _Internet_, it only guarantees the network
+connection.
+
+## Usage
+
+```jsx
+import {useNetworkState} from 'react-use';
+
+const Demo = () => {
+ const state = useNetworkState();
+
+ return (
+
+ {JSON.stringify(state, null, 2)}
+
+ );
+};
+```
+
+#### State interface:
+
+```typescript
+interface IUseNetworkState {
+ /**
+ * @desc Whether browser connected to the network or not.
+ */
+ online: boolean | undefined;
+ /**
+ * @desc Previous value of `online` property. Helps to identify if browser
+ * just connected or lost connection.
+ */
+ previous: boolean | undefined;
+ /**
+ * @desc The {Date} object pointing to the moment when state change occurred.
+ */
+ since: Date | undefined;
+ /**
+ * @desc Effective bandwidth estimate in megabits per second, rounded to the
+ * nearest multiple of 25 kilobits per seconds.
+ */
+ downlink: number | undefined;
+ /**
+ * @desc Maximum downlink speed, in megabits per second (Mbps), for the
+ * underlying connection technology
+ */
+ downlinkMax: number | undefined;
+ /**
+ * @desc Effective type of the connection meaning one of 'slow-2g', '2g', '3g', or '4g'.
+ * This value is determined using a combination of recently observed round-trip time
+ * and downlink values.
+ */
+ effectiveType: 'slow-2g' | '2g' | '3g' | '4g' | undefined;
+ /**
+ * @desc Estimated effective round-trip time of the current connection, rounded
+ * to the nearest multiple of 25 milliseconds
+ */
+ rtt: number | undefined;
+ /**
+ * @desc Wheter user has set a reduced data usage option on the user agent.
+ */
+ saveData: boolen | undefined;
+ /**
+ * @desc The type of connection a device is using to communicate with the network.
+ */
+ type: 'bluetooth' | 'cellular' | 'ethernet' | 'none' | 'wifi' | 'wimax' | 'other' | 'unknown' | undefined;
+}
+```
+
+#### Call signature
+
+```typescript
+function useNetworkState(initialState?: IUseNetworkState | (() => IUseNetworkState)): IUseNetworkState;
+```
diff --git a/docs/usePageLeave.md b/docs/usePageLeave.md
new file mode 100644
index 0000000000..4d06abe77e
--- /dev/null
+++ b/docs/usePageLeave.md
@@ -0,0 +1,15 @@
+# `usePageLeave`
+
+React sensor hook that fires a callback when mouse leaves the page.
+
+## Usage
+
+```jsx
+import {usePageLeave} from 'react-use';
+
+const Demo = () => {
+ usePageLeave(() => console.log('Page left...'));
+
+ return null;
+};
+```
diff --git a/docs/usePermission.md b/docs/usePermission.md
new file mode 100644
index 0000000000..4c0080b22d
--- /dev/null
+++ b/docs/usePermission.md
@@ -0,0 +1,19 @@
+# `usePermission`
+
+React side-effect hook to query permission status of browser APIs.
+
+## Usage
+
+```jsx
+import {usePermission} from 'react-use';
+
+const Demo = () => {
+ const state = usePermission({ name: 'microphone' });
+
+ return (
+
+ {JSON.stringify(state, null, 2)}
+
+ );
+};
+```
diff --git a/docs/usePinchZoom.md b/docs/usePinchZoom.md
new file mode 100644
index 0000000000..12449fac4e
--- /dev/null
+++ b/docs/usePinchZoom.md
@@ -0,0 +1,36 @@
+# `usePinchZoom`
+
+React sensor hook that tracks the changes in pointer touch events and detects value of pinch difference and tell if user is zooming in or out.
+
+## Usage
+
+```jsx
+import { usePinchZoom } from "react-use";
+
+const Demo = () => {
+ const [scale, setState] = useState(1);
+ const scaleRef = useRef();
+ const { zoomingState, pinchState } = usePinchZoom(scaleRef);
+
+ useEffect(() => {
+ if (zoomingState === "ZOOM_IN") {
+ // perform zoom in scaling
+ setState(scale + 0.1)
+ } else if (zoomingState === "ZOOM_OUT") {
+ // perform zoom out in scaling
+ setState(scale - 0.1)
+ }
+ }, [zoomingState]);
+
+ return (
+
+ + + +
+ Now: {count}, before: {prevCount} +
+ + ); +}; +``` + +## Reference + +```ts +const prevState = usePrevious =+ Now: {count}, before: {prevCount} + + Unrelated: {unrelatedCount} + +
+ ); +}; +``` + +You can also provide a way of identifying the value as unique. By default, a strict equals is used. + +```jsx +import {usePreviousDistinct} from 'react-use'; + +const Demo = () => { + const [str, setStr] = React.useState("something_lowercase"); + const [unrelatedCount] = React.useState(0); + const prevStr = usePreviousDistinct(str, (prev, next) => (prev && prev.toUpperCase()) === next.toUpperCase()); + + return ( ++ Now: {count}, before: {prevCount} + Unrelated: {unrelatedCount} +
+ ); +}; +``` + +## Reference + +```ts +const prevState = usePreviousDistinct ={JSON.stringify(state, null, 2)};
+};
+```
diff --git a/docs/useRefMounted.md b/docs/useRefMounted.md
deleted file mode 100644
index 01158dae3e..0000000000
--- a/docs/useRefMounted.md
+++ /dev/null
@@ -1,25 +0,0 @@
-# `useRefMounted`
-
-Lifecycle hook that tracks if component is mounted. Returns a ref, which has a
-boolean `.current` property.
-
-
-## Usage
-
-```jsx
-import {useRefMounted} from 'react-use';
-
-const Demo = () => {
- const refMounted = useRefMounted();
-
- useEffect(() => {
- setTimeout(() => {
- if (refMounted.currrent) {
- // ...
- } else {
- // ...
- }
- }, 1000);
- });
-};
-```
diff --git a/docs/useRendersCount.md b/docs/useRendersCount.md
new file mode 100644
index 0000000000..134049939e
--- /dev/null
+++ b/docs/useRendersCount.md
@@ -0,0 +1,29 @@
+# `useRendersCount`
+
+Tracks component's renders count including the first render.
+
+## Usage
+
+```typescript jsx
+import * as React from 'react';
+import { useRendersCount } from "react-use";
+
+const Demo = () => {
+ const update = useUpdate();
+ const rendersCount = useRendersCount();
+
+ return (
+ {JSON.stringify(state, null, 4)}
+ {state.isScratching && }
+ {JSON.stringify(Array.from(set), null, 2)}
+ useShallowCompareEffect: {count}
++ {Math.round(value * 100)}% +
+
diff --git a/docs/useSpring.md b/docs/useSpring.md
index 9353323525..1a9271bd7c 100644
--- a/docs/useSpring.md
+++ b/docs/useSpring.md
@@ -3,11 +3,10 @@
React animation hook that updates a single numeric value over time according
to spring dynamics.
-
## Usage
```jsx
-import {useSpring} from 'react-use';
+import useSpring from 'react-use/lib/useSpring';
const Demo = () => {
const [target, setTarget] = useState(50);
@@ -24,9 +23,19 @@ const Demo = () => {
};
```
+Note: Because of dependency on `rebound` you have to import this hook directly like shown above.
+
+## Requirements
-# Reference
+Install [`rebound`](https://github.com/facebook/rebound-js) peer dependency:
+
+```bash
+npm add rebound
+# or
+yarn add rebound
+```
+## Reference
```js
const currentValue = useSpring(targetValue);
diff --git a/docs/useStartTyping.md b/docs/useStartTyping.md
new file mode 100644
index 0000000000..b43c143bab
--- /dev/null
+++ b/docs/useStartTyping.md
@@ -0,0 +1,16 @@
+# `useStartTyping`
+
+React sensor hook that fires a callback when user starts typing. Can be used
+to focus default input field on the page.
+
+## Usage
+
+```jsx
+import {useStartTyping} from 'react-use';
+
+const Demo = () => {
+ useStartTyping(() => alert('Started typing...'));
+
+ return null;
+};
+```
diff --git a/docs/useStateList.md b/docs/useStateList.md
new file mode 100644
index 0000000000..21cf8f8d1b
--- /dev/null
+++ b/docs/useStateList.md
@@ -0,0 +1,54 @@
+# `useStateList`
+
+Provides handles for circular iteration over states list.
+Supports forward and backward iterations and arbitrary position set.
+
+## Usage
+
+```jsx
+import { useStateList } from 'react-use';
+import { useRef } from 'react';
+
+const stateSet = ['first', 'second', 'third', 'fourth', 'fifth'];
+
+const Demo = () => {
+ const { state, prev, next, setStateAt, setState, currentIndex, isFirst, isLast } = useStateList(stateSet);
+ const indexInput = useRef(null);
+ const stateInput = useRef(null);
+
+ return (
+
+
+ {state} [index: {currentIndex}], [isFirst: {isFirst}], [isLast: {isLast}]
+
+
+
+
+
+
+
+
+
+
+
+ );
+};
+```
+
+## Reference
+
+```ts
+const { state, currentIndex, prev, next, setStateAt, setState, isFirst, isLast } = useStateList(stateSet: T[] = []);
+```
+
+If `stateSet` changed, became shorter than before and `currentIndex` left in shrunk gap - the last element of list will be taken as current.
+
+- **`state`**_`: T`_ — current state value;
+- **`currentIndex`**_`: number`_ — current state index;
+- **`prev()`**_`: void`_ — switches state to the previous one. If first element selected it will switch to the last one;
+- **`next()`**_`: void`_ — switches state to the next one. If last element selected it will switch to the first one;
+- **`setStateAt(newIndex: number)`**_`: void`_ — set the arbitrary state by index. Indexes are looped, and can be negative.
+ _4ex:_ if list contains 5 elements, attempt to set index 9 will bring use to the 5th element, in case of negative index it will start counting from the right, so -17 will bring us to the 4th element.
+- **`setState(state: T)`**_`: void`_ — set the arbitrary state value that exists in `stateSet`. _In case new state does not exists in `stateSet` an Error will be thrown._
+- **`isFirst`**_`: boolean`_ — `true` if current state is the first one.
+- **`isLast`**_`: boolean`_ — `true` if current state is the last one.
diff --git a/docs/useStateValidator.md b/docs/useStateValidator.md
new file mode 100644
index 0000000000..0b434fcaf9
--- /dev/null
+++ b/docs/useStateValidator.md
@@ -0,0 +1,47 @@
+# `useStateValidator`
+
+Each time given state changes - validator function is invoked.
+
+## Usage
+```ts
+import * as React from 'react';
+import { useCallback } from 'react';
+import { useStateValidator } from 'react-use';
+
+const DemoStateValidator = s => [s === '' ? null : (s * 1) % 2 === 0];
+const Demo = () => {
+ const [state, setState] = React.useState(0);
+ const [[isValid]] = useStateValidator(state, DemoStateValidator);
+
+ return (
+
+ Below field is valid only if number is even
+ ) => {
+ setState(ev.target.value);
+ }}
+ />
+ {isValid !== null && {isValid ? 'Valid!' : 'Invalid'}}
+
+ );
+};
+```
+
+## Reference
+```ts
+const [validity, revalidate] = useStateValidator(
+ state: any,
+ validator: (state, setValidity?)=>[boolean|null, ...any[]],
+ initialValidity: any
+);
+```
+- **`validity`**_`: [boolean|null, ...any[]]`_ result of validity check. First element is strictly nullable boolean, but others can contain arbitrary data;
+- **`revalidate`**_`: ()=>void`_ runs validator once again
+- **`validator`**_`: (state, setValidity?)=>[boolean|null, ...any[]]`_ should return an array suitable for validity state described above;
+ - `state` - current state;
+ - `setValidity` - if defined hook will not trigger validity change automatically. Useful for async validators;
+- `initialValidity` - validity value which set when validity is nt calculated yet;
diff --git a/docs/useStateWithHistory.md b/docs/useStateWithHistory.md
new file mode 100644
index 0000000000..fe6dcbcbf4
--- /dev/null
+++ b/docs/useStateWithHistory.md
@@ -0,0 +1,33 @@
+# `useStateHistory`
+
+Stores defined amount of previous state values and provides handles to travel through them.
+
+## Usage
+
+## Reference
+
+```typescript
+const [state, setState, stateHistory] = useStateWithHistory(
+ initialState?: S | (()=>S),
+ capacity?: number = 10,
+ initialHistory?: S
+);
+```
+
+- **`state`**, **`setState`** and **`initialState`** are exactly the same with native React's `useState` hook;
+- **`capacity`** - amount of history entries held by storage;
+- **`initialHistory`** - if defined it will be used as initial history value, otherwise history will equal `[ initialState ]`.
+Initial state will not be pushed to initial history.
+If entries amount is greater than `capacity` parameter it won't be modified on init but will be trimmed on the next call to `setState`;
+- **`stateHistory`** - an object containing history state:
+ - **`history`**_`: S[]`_ - an array holding history entries. _It will have the same ref all the time so be careful with that one!_;
+ - **`position`**_`: number`_ - current position _index_ in history;
+ - **`capacity`**_`: number = 10`_ - maximum amount of history entries;
+ - **`back`**_`: (amount?: number) => void`_ - go back in state history, it will cause `setState` to be invoked and component re-render.
+ If first element of history reached, the call will have no effect;
+ - **`forward`**_`: (amount?: number) => void`_ - go forward in state history, it will cause `setState` to be invoked and component re-render.
+ If last element of history is reached, the call will have no effect;
+ - **`go`**_`: (position: number) => void`_ - go to arbitrary position in history.
+ In case `position` is non-negative ot will count elements from beginning.
+ Negative `position` will cause elements counting from the end, so `go(-2)` equals `go(history.length - 1)`;
+
diff --git a/docs/useThrottle.md b/docs/useThrottle.md
new file mode 100644
index 0000000000..7557cee256
--- /dev/null
+++ b/docs/useThrottle.md
@@ -0,0 +1,29 @@
+# `useThrottle` and `useThrottleFn`
+
+React hooks that throttle.
+
+## Usage
+
+```jsx
+import React, { useState } from 'react';
+import { useThrottle, useThrottleFn } from 'react-use';
+
+const Demo = ({value}) => {
+ const throttledValue = useThrottle(value);
+ // const throttledValue = useThrottleFn(value => value, 200, [value]);
+
+ return (
+ <>
+ Value: {value}
+ Throttled value: {throttledValue}
+ >
+ );
+};
+```
+
+## Reference
+
+```ts
+useThrottle(value, ms?: number);
+useThrottleFn(fn, ms, args);
+```
diff --git a/docs/useThrottleFn.md b/docs/useThrottleFn.md
new file mode 100644
index 0000000000..db64375b92
--- /dev/null
+++ b/docs/useThrottleFn.md
@@ -0,0 +1,49 @@
+# `useThrottleFn`
+
+React hook that invokes a function and then delays subsequent function calls until after wait milliseconds have elapsed since the last time the throttled function was invoked.
+
+The third argument is the array of values that the throttle depends on, in the same manner as useEffect. The throttle timeout will start when one of the values changes.
+
+## Usage
+
+```jsx
+import React, { useState } from 'react';
+import { useThrottleFn } from 'react-use';
+
+const Demo = () => {
+ const [status, setStatus] = React.useState('Updating stopped');
+ const [value, setValue] = React.useState('');
+ const [throttledValue, setThrottledValue] = React.useState('');
+
+ useThrottleFn(
+ () => {
+ setStatus('Waiting for input...');
+ setThrottledValue(value);
+ },
+ 2000,
+ [value]
+ );
+
+ return (
+
+ {
+ setStatus('Updating stopped');
+ setValue(currentTarget.value);
+ }}
+ />
+ {status}
+ Throttled value: {throttledValue}
+
+ );
+};
+```
+
+## Reference
+
+```ts
+useThrottleFn(fn, ms: number, args: any[]);
+```
diff --git a/docs/useTimeout.md b/docs/useTimeout.md
index 4c4c96e217..6c09e62c7d 100644
--- a/docs/useTimeout.md
+++ b/docs/useTimeout.md
@@ -1,15 +1,48 @@
# `useTimeout`
-Returns `true` after a specified number of milliseconds.
+Re-renders the component after a specified number of milliseconds.
+Provides handles to cancel and/or reset the timeout.
## Usage
```jsx
import { useTimeout } from 'react-use';
-const Demo = () => {
- const ready = useTimeout(2000);
+function TestComponent(props: { ms?: number } = {}) {
+ const ms = props.ms || 5000;
+ const [isReady, cancel] = useTimeout(ms);
+
+ return (
+
+ { isReady() ? 'I\'m reloaded after timeout' : `I will be reloaded after ${ ms / 1000 }s` }
+ { isReady() === false ? : '' }
+
+ );
+}
- return Ready: {ready ? 'Yes' : 'No'};
+const Demo = () => {
+ return (
+
+
+
+
+ );
};
```
+
+## Reference
+
+```ts
+const [
+ isReady: () => boolean | null,
+ cancel: () => void,
+ reset: () => void,
+] = useTimeout(ms: number = 0);
+```
+
+- **`isReady`**_` :()=>boolean|null`_ - function returning current timeout state:
+ - `false` - pending re-render
+ - `true` - re-render performed
+ - `null` - re-render cancelled
+- **`cancel`**_` :()=>void`_ - cancel the timeout (component will not be re-rendered)
+- **`reset`**_` :()=>void`_ - reset the timeout
diff --git a/docs/useTimeoutFn.md b/docs/useTimeoutFn.md
new file mode 100644
index 0000000000..48e4bc2d99
--- /dev/null
+++ b/docs/useTimeoutFn.md
@@ -0,0 +1,68 @@
+# `useTimeoutFn`
+
+Calls given function after specified amount of milliseconds.
+
+Several thing about it's work:
+- does not re-render component;
+- automatically cancel timeout on cancel;
+- automatically reset timeout on delay change;
+- reset function call will cancel previous timeout;
+- timeout will NOT be reset on function change. It will be called within the timeout, you have to reset it on your own when needed.
+
+## Usage
+
+```jsx
+import * as React from 'react';
+import { useTimeoutFn } from 'react-use';
+
+const Demo = () => {
+ const [state, setState] = React.useState('Not called yet');
+
+ function fn() {
+ setState(`called at ${Date.now()}`);
+ }
+
+ const [isReady, cancel, reset] = useTimeoutFn(fn, 5000);
+ const cancelButtonClick = useCallback(() => {
+ if (isReady() === false) {
+ cancel();
+ setState(`cancelled`);
+ } else {
+ reset();
+ setState('Not called yet');
+ }
+ }, []);
+
+ const readyState = isReady();
+
+ return (
+
+ {readyState !== null ? 'Function will be called in 5 seconds' : 'Timer cancelled'}
+
+
+ Function state: {readyState === false ? 'Pending' : readyState ? 'Called' : 'Cancelled'}
+ {state}
+
+ );
+};
+```
+
+## Reference
+
+```ts
+const [
+ isReady: () => boolean | null,
+ cancel: () => void,
+ reset: () => void,
+] = useTimeoutFn(fn: Function, ms: number = 0);
+```
+
+- **`fn`**_`: Function`_ - function that will be called;
+- **`ms`**_`: number`_ - delay in milliseconds;
+- **`isReady`**_`: ()=>boolean|null`_ - function returning current timeout state:
+ - `false` - pending
+ - `true` - called
+ - `null` - cancelled
+- **`cancel`**_`: ()=>void`_ - cancel the timeout
+- **`reset`**_`: ()=>void`_ - reset the timeout
+
diff --git a/docs/useToggle.md b/docs/useToggle.md
index 93a4e4ec3b..0405c6ce18 100644
--- a/docs/useToggle.md
+++ b/docs/useToggle.md
@@ -4,11 +4,10 @@ React state hook that tracks value of a boolean.
`useBoolean` is an alias for `useToggle`.
-
## Usage
```jsx
-import {useToggle, useBoolean} from 'react-use';
+import {useToggle} from 'react-use';
const Demo = () => {
const [on, toggle] = useToggle(true);
@@ -16,7 +15,7 @@ const Demo = () => {
return (
{on ? 'ON' : 'OFF'}
-
+
diff --git a/docs/useTween.md b/docs/useTween.md
index 19879e67b3..bef2fad113 100644
--- a/docs/useTween.md
+++ b/docs/useTween.md
@@ -2,8 +2,6 @@
React animation hook that tweens a number between 0 and 1.
-[](https://codesandbox.io/s/52990wwzyl)
-
## Usage
@@ -21,7 +19,6 @@ const Demo = () => {
};
```
-
## Reference
```ts
diff --git a/docs/useUnmount.md b/docs/useUnmount.md
index c33358d177..a887e222a0 100644
--- a/docs/useUnmount.md
+++ b/docs/useUnmount.md
@@ -1,8 +1,6 @@
# `useUnmount`
-React lifecycle hook that call `unmount` callback, when
-component is un-mounted.
-
+React lifecycle hook that calls a function when the component will unmount. Use `useLifecycles` if you need both a mount and unmount function.
## Usage
@@ -10,14 +8,13 @@ component is un-mounted.
import {useUnmount} from 'react-use';
const Demo = () => {
- useUnmount(() => console.log('UNMOUNTED'));
+ useUnmount(() => alert('UNMOUNTED'));
return null;
};
```
-
## Reference
-```js
-useUnmount(mount);
+```ts
+useUnmount(fn: () => void | undefined);
```
diff --git a/docs/useUnmountPromise.md b/docs/useUnmountPromise.md
new file mode 100644
index 0000000000..5a129cb936
--- /dev/null
+++ b/docs/useUnmountPromise.md
@@ -0,0 +1,30 @@
+# `useUnmountPromise`
+
+A life-cycle hook that provides a higher order promise that does not resolve if component un-mounts.
+
+
+## Usage
+
+```ts
+import useUnmountPromise from 'react-use/lib/useUnmountPromise';
+
+const Demo = () => {
+ const mounted = useUnmountPromise();
+ useEffect(async () => {
+ await mounted(someFunction()); // Will not resolve if component un-mounts.
+ });
+};
+```
+
+
+## Reference
+
+```ts
+const mounted = useUnmountPromise();
+
+mounted(promise);
+mounted(promise, onError);
+```
+
+- `onError` — if promise rejects after the component is unmounted, `onError`
+ callback is called with the error.
diff --git a/docs/useUpdateEffect.md b/docs/useUpdateEffect.md
new file mode 100644
index 0000000000..ca3c7f6d75
--- /dev/null
+++ b/docs/useUpdateEffect.md
@@ -0,0 +1,35 @@
+# `useUpdateEffect`
+
+React effect hook that ignores the first invocation (e.g. on mount). The signature is exactly the same as the `useEffect` hook.
+
+
+## Usage
+
+```jsx
+import React from 'react'
+import {useUpdateEffect} from 'react-use';
+
+const Demo = () => {
+ const [count, setCount] = React.useState(0);
+
+ React.useEffect(() => {
+ const interval = setInterval(() => {
+ setCount(count => count + 1)
+ }, 1000)
+
+ return () => {
+ clearInterval(interval)
+ }
+ }, [])
+
+ useUpdateEffect(() => {
+ console.log('count', count) // will only show 1 and beyond
+
+ return () => { // *OPTIONAL*
+ // do something on unmount
+ }
+ }) // you can include deps array if necessary
+
+ return Count: {count}
+};
+```
diff --git a/docs/useUpsert.md b/docs/useUpsert.md
new file mode 100644
index 0000000000..25fe7d71fd
--- /dev/null
+++ b/docs/useUpsert.md
@@ -0,0 +1,36 @@
+# `useUpsert`
+
+> DEPRECATED!
+> Use `useList` hook's upsert action instead
+
+Superset of [`useList`](./useList.md). Provides an additional method to upsert (update or insert) an element into the list.
+
+## Usage
+
+```jsx
+import {useUpsert} from 'react-use';
+
+const Demo = () => {
+ const comparisonFunction = (a: DemoType, b: DemoType) => {
+ return a.id === b.id;
+ };
+ const [list, { set, upsert, remove }] = useUpsert(comparisonFunction, initialItems);
+
+ return (
+
+ {list.map((item: DemoType, index: number) => (
+
+ upsert({ ...item, text: e.target.value })} />
+
+
+ ))}
+
+
+
+ );
+};
+```
+
+## Related hooks
+
+- [useList](./useList.md)
diff --git a/docs/useVibrate.md b/docs/useVibrate.md
new file mode 100644
index 0000000000..957d01149f
--- /dev/null
+++ b/docs/useVibrate.md
@@ -0,0 +1,31 @@
+# `useVibrate`
+
+React UI hook to provide physical feedback with device vibration hardware using the [Vibration API](https://developer.mozilla.org/en-US/docs/Web/API/Vibration_API).
+
+## Usage
+
+```jsx
+import {useVibrate} from 'react-use';
+
+const Demo = () => {
+ const [vibrating, toggleVibrating] = useToggle(false);
+
+ useVibrate(vibrating, [300, 100, 200, 100, 1000, 300], false);
+
+ return (
+
+
+
+ );
+};
+```
+
+## Reference
+
+```ts
+useVibrate(
+ enabled: boolean = true,
+ pattern: number | number[] = [1000, 1000],
+ loop: boolean = true
+): void;
+```
diff --git a/docs/useVideo.md b/docs/useVideo.md
index ab8725eb31..7d0dfb9257 100644
--- a/docs/useVideo.md
+++ b/docs/useVideo.md
@@ -61,7 +61,7 @@ render tree, for example:
],
"time": 5.244996,
"duration": 425.952625,
- "isPlaying": false,
+ "paused": false,
"muted": false,
"volume": 1
}
@@ -84,4 +84,4 @@ interface AudioControls {
`ref` is a React reference to HTML `
- {JSON.stringify(state, null, 2)}
-
- );
-};
-
-storiesOf('Sensors/useBattery', module)
- .add('Docs', () =>
- {JSON.stringify(state, null, 2)}
-
- );
-};
-
-storiesOf('Sensors/useGeolocation', module)
- .add('Docs', () => Q W E R T Y
- {!hasPressedWord && (
-
- {JSON.stringify(state, null, 2)}
-
- );
-};
-
-storiesOf('Sensors/useLocation', module)
- .add('Docs', () => {JSON.stringify(map, null, 2)}
-
-
-
- {JSON.stringify(state, null, 2)}
-
- );
-};
-
-storiesOf('Sensors/useMediaDevices', module)
- .add('Docs', () =>
- {JSON.stringify(state, null, 2)}
-
- );
-};
-
-storiesOf('Sensors/useMotion', module)
- .add('Docs', () =>
- {JSON.stringify(state, null, 2)}
-
- );
-};
-
-storiesOf('Sensors/useNetwork', module)
- .add('Docs', () =>
- {JSON.stringify(state, null, 2)}
-
- );
-};
-
-storiesOf('Sensors/useOrientation', module)
- .add('Docs', () =>
- {JSON.stringify(state, null, 2)}
-
- );
-};
-
-storiesOf('UI/useSpeech', module)
- .add('Docs', () => - { isWaiting('creating user') ? "Now creating user..." : "" } -
-} - -const Demo = () => { - const { Wait, isWaiting, startWaiting, endWaiting } = useWait(); - - function createUser() { - startWaiting('creating user'); - setTimeout(() => { - endWaiting('creating user'); - }, 1000) - } - - return ( -