Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: streamich/react-use
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v12.3.0
Choose a base ref
...
head repository: streamich/react-use
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v12.3.1
Choose a head ref
  • 6 commits
  • 4 files changed
  • 4 contributors

Commits on Oct 8, 2019

  1. Copy the full SHA
    c1484cb View commit details
  2. Copy the full SHA
    b1944a1 View commit details
  3. Copy the full SHA
    706f660 View commit details

Commits on Oct 10, 2019

  1. tests: useFavicon (#666)

    kevinnorris authored and wardoost committed Oct 10, 2019
    Copy the full SHA
    d1aaa85 View commit details
  2. Unverified

    This commit is not signed, but one or more authors requires that any commit attributed to them is signed.
    Copy the full SHA
    6bdd74e View commit details
  3. chore(release): 12.3.1 [skip ci]

    ## [12.3.1](v12.3.0...v12.3.1) (2019-10-10)
    
    ### Bug Fixes
    
    * move [@types](https://github.com/types)/react-wait to dependencies, closes [#661](#661) ([#662](#662)) ([6bdd74e](6bdd74e))
    semantic-release-bot committed Oct 10, 2019
    Copy the full SHA
    823f94f View commit details
Showing with 147 additions and 35 deletions.
  1. +7 βˆ’0 CHANGELOG.md
  2. +7 βˆ’7 package.json
  3. +55 βˆ’0 src/__tests__/useFavicon.test.tsx
  4. +78 βˆ’28 yarn.lock
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## [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)


14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-use",
"version": "12.3.0",
"version": "12.3.1",
"description": "Collection of React Hooks",
"main": "lib/index.js",
"module": "esm/index.js",
@@ -45,6 +45,7 @@
},
"homepage": "https://github.com/streamich/react-use#readme",
"dependencies": {
"@types/react-wait": "^0.3.0",
"copy-to-clipboard": "^3.1.0",
"nano-css": "^5.1.0",
"react-fast-compare": "^2.0.4",
@@ -60,10 +61,10 @@
"react-dom": "^16.8.0"
},
"devDependencies": {
"@babel/core": "7.6.2",
"@babel/core": "7.6.3",
"@babel/plugin-syntax-dynamic-import": "7.2.0",
"@babel/preset-env": "7.6.2",
"@babel/preset-react": "7.0.0",
"@babel/preset-env": "7.6.3",
"@babel/preset-react": "7.6.3",
"@babel/preset-typescript": "7.6.0",
"@semantic-release/changelog": "3.0.4",
"@semantic-release/git": "7.0.16",
@@ -76,7 +77,6 @@
"@testing-library/react-hooks": "2.0.3",
"@types/jest": "24.0.18",
"@types/react": "16.9.2",
"@types/react-wait": "0.3.0",
"babel-core": "6.26.3",
"babel-loader": "8.0.6",
"babel-plugin-dynamic-import-node": "2.3.0",
@@ -85,7 +85,7 @@
"husky": "3.0.8",
"jest": "24.9.0",
"keyboardjs": "2.5.1",
"lint-staged": "9.4.1",
"lint-staged": "9.4.2",
"markdown-loader": "5.1.0",
"prettier": "1.18.2",
"raf-stub": "3.0.0",
@@ -141,7 +141,7 @@
},
"volta": {
"node": "10.16.3",
"yarn": "1.19.0"
"yarn": "1.19.1"
},
"collective": {
"type": "opencollective",
55 changes: 55 additions & 0 deletions src/__tests__/useFavicon.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { renderHook } from '@testing-library/react-hooks';
import useFavicon from '../useFavicon';

afterEach(() => {
const favicon = document.querySelector("link[rel*='icon']");
if (favicon) {
favicon.remove();
}
});

describe('useFavicon', () => {
it('should be defined', () => {
expect(useFavicon).toBeDefined();
});

it('should create a HTMLLinkElement', () => {
const faviconBeforeHook = document.querySelector("link[rel*='icon']");

expect(faviconBeforeHook).toBe(null);
renderHook(() => useFavicon('My-favicon'));

const faviconAfterHook = document.querySelector("link[rel*='icon']");
expect(faviconAfterHook).toBeInstanceOf(HTMLLinkElement);
});

it('should set the elements type to "image/x-icon"', () => {
renderHook(() => useFavicon('My-favicon'));
const favicon = document.querySelector("link[rel*='icon']") as HTMLLinkElement;

expect(favicon.type).toBe('image/x-icon');
});

it('should set the elements rel to "shortcut icon"', () => {
renderHook(() => useFavicon('My-favicon'));
const favicon = document.querySelector("link[rel*='icon']") as HTMLLinkElement;

expect(favicon.rel).toBe('shortcut icon');
});

it('should set the elements href to the provided string', () => {
renderHook(() => useFavicon('https://github.com/streamich/react-use'));
const favicon = document.querySelector("link[rel*='icon']") as HTMLLinkElement;

expect(favicon.href).toBe('https://github.com/streamich/react-use');
});

it('should update an existing favicon', () => {
const hook = renderHook(props => useFavicon(props), { initialProps: 'https://github.com/streamich/react-use' });
const favicon = document.querySelector("link[rel*='icon']") as HTMLLinkElement;

expect(favicon.href).toBe('https://github.com/streamich/react-use');
hook.rerender('https://en.wikipedia.org/wiki/Favicon');
expect(favicon.href).toBe('https://en.wikipedia.org/wiki/Favicon');
});
});
106 changes: 78 additions & 28 deletions yarn.lock
Original file line number Diff line number Diff line change
@@ -36,25 +36,25 @@
semver "^5.4.1"
source-map "^0.5.0"

"@babel/core@7.6.2":
version "7.6.2"
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.6.2.tgz#069a776e8d5e9eefff76236bc8845566bd31dd91"
integrity sha512-l8zto/fuoZIbncm+01p8zPSDZu/VuuJhAfA7d/AbzM09WR7iVhavvfNDYCNpo1VvLk6E6xgAoP9P+/EMJHuRkQ==
"@babel/core@7.6.3":
version "7.6.3"
resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.6.3.tgz#44de824e89eaa089bb12da7337bc9bdff2ab68f9"
integrity sha512-QfQ5jTBgXLzJuo7Mo8bZK/ePywmgNRgk/UQykiKwEtZPiFIn8ZqE6jB+AnD1hbB1S2xQyL4//it5vuAUOVAMTw==
dependencies:
"@babel/code-frame" "^7.5.5"
"@babel/generator" "^7.6.2"
"@babel/generator" "^7.6.3"
"@babel/helpers" "^7.6.2"
"@babel/parser" "^7.6.2"
"@babel/parser" "^7.6.3"
"@babel/template" "^7.6.0"
"@babel/traverse" "^7.6.2"
"@babel/types" "^7.6.0"
"@babel/traverse" "^7.6.3"
"@babel/types" "^7.6.3"
convert-source-map "^1.1.0"
debug "^4.1.0"
json5 "^2.1.0"
lodash "^4.17.13"
resolve "^1.3.2"
semver "^5.4.1"
source-map "^0.5.0"
source-map "^0.6.1"

"@babel/core@^7.0.0", "@babel/core@^7.1.0", "@babel/core@^7.4.5":
version "7.5.5"
@@ -97,6 +97,16 @@
lodash "^4.17.13"
source-map "^0.5.0"

"@babel/generator@^7.6.3":
version "7.6.3"
resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.6.3.tgz#71d5375264f93ec7bac7d9f35a67067733f5578e"
integrity sha512-hLhYbAb3pHwxjlijC4AQ7mqZdcoujiNaW7izCT04CIowHK8psN0IN8QjDv0iyFtycF5FowUOTwDloIheI25aMw==
dependencies:
"@babel/types" "^7.6.3"
jsesc "^2.5.1"
lodash "^4.17.13"
source-map "^0.6.1"

"@babel/helper-annotate-as-pure@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.0.0.tgz#323d39dd0b50e10c7c06ca7d7638e6864d8c5c32"
@@ -326,6 +336,11 @@
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.6.2.tgz#205e9c95e16ba3b8b96090677a67c9d6075b70a1"
integrity sha512-mdFqWrSPCmikBoaBYMuBulzTIKuXVPtEISFbRRVNwMWpCms/hmE2kRq0bblUHaNRKrjRlmVbx1sDHmjmRgD2Xg==

"@babel/parser@^7.6.3":
version "7.6.3"
resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.6.3.tgz#9eff8b9c3eeae16a74d8d4ff30da2bd0d6f0487e"
integrity sha512-sUZdXlva1dt2Vw2RqbMkmfoImubO0D0gaCrNngV6Hi0DA4x3o4mlrq0tbfY0dZEUIccH8I6wQ4qgEtwcpOR6Qg==

"@babel/plugin-proposal-async-generator-functions@^7.2.0":
version "7.2.0"
resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.2.0.tgz#b289b306669dce4ad20b0252889a15768c9d417e"
@@ -512,10 +527,10 @@
"@babel/helper-plugin-utils" "^7.0.0"
lodash "^4.17.13"

"@babel/plugin-transform-block-scoping@^7.6.2":
version "7.6.2"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.6.2.tgz#96c33ab97a9ae500cc6f5b19e04a7e6553360a79"
integrity sha512-zZT8ivau9LOQQaOGC7bQLQOT4XPkPXgN2ERfUgk1X8ql+mVkLc4E8eKk+FO3o0154kxzqenWCorfmEXpEZcrSQ==
"@babel/plugin-transform-block-scoping@^7.6.3":
version "7.6.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-block-scoping/-/plugin-transform-block-scoping-7.6.3.tgz#6e854e51fbbaa84351b15d4ddafe342f3a5d542a"
integrity sha512-7hvrg75dubcO3ZI2rjYTzUrEuh1E9IyDEhhB6qfcooxhDA33xx2MasuLVgdxzcP6R/lipAC6n9ub9maNW6RKdw==
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"
lodash "^4.17.13"
@@ -699,10 +714,10 @@
dependencies:
regexp-tree "^0.1.6"

"@babel/plugin-transform-named-capturing-groups-regex@^7.6.2":
version "7.6.2"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.6.2.tgz#c1ca0bb84b94f385ca302c3932e870b0fb0e522b"
integrity sha512-xBdB+XOs+lgbZc2/4F5BVDVcDNS4tcSKQc96KmlqLEAwz6tpYPEvPdmDfvVG0Ssn8lAhronaRs6Z6KSexIpK5g==
"@babel/plugin-transform-named-capturing-groups-regex@^7.6.3":
version "7.6.3"
resolved "https://registry.yarnpkg.com/@babel/plugin-transform-named-capturing-groups-regex/-/plugin-transform-named-capturing-groups-regex-7.6.3.tgz#aaa6e409dd4fb2e50b6e2a91f7e3a3149dbce0cf"
integrity sha512-jTkk7/uE6H2s5w6VlMHeWuH+Pcy2lmdwFoeWCVnvIrDUnB5gQqTVI8WfmEAhF2CDEarGrknZcmSFg1+bkfCoSw==
dependencies:
regexpu-core "^4.6.0"

@@ -934,10 +949,10 @@
js-levenshtein "^1.1.3"
semver "^5.5.0"

"@babel/preset-env@7.6.2":
version "7.6.2"
resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.6.2.tgz#abbb3ed785c7fe4220d4c82a53621d71fc0c75d3"
integrity sha512-Ru7+mfzy9M1/YTEtlDS8CD45jd22ngb9tXnn64DvQK3ooyqSw9K4K9DUWmYknTTVk4TqygL9dqCrZgm1HMea/Q==
"@babel/preset-env@7.6.3":
version "7.6.3"
resolved "https://registry.yarnpkg.com/@babel/preset-env/-/preset-env-7.6.3.tgz#9e1bf05a2e2d687036d24c40e4639dc46cef2271"
integrity sha512-CWQkn7EVnwzlOdR5NOm2+pfgSNEZmvGjOhlCHBDq0J8/EStr+G+FvPEiz9B56dR6MoiUFjXhfE4hjLoAKKJtIQ==
dependencies:
"@babel/helper-module-imports" "^7.0.0"
"@babel/helper-plugin-utils" "^7.0.0"
@@ -955,7 +970,7 @@
"@babel/plugin-transform-arrow-functions" "^7.2.0"
"@babel/plugin-transform-async-to-generator" "^7.5.0"
"@babel/plugin-transform-block-scoped-functions" "^7.2.0"
"@babel/plugin-transform-block-scoping" "^7.6.2"
"@babel/plugin-transform-block-scoping" "^7.6.3"
"@babel/plugin-transform-classes" "^7.5.5"
"@babel/plugin-transform-computed-properties" "^7.2.0"
"@babel/plugin-transform-destructuring" "^7.6.0"
@@ -970,7 +985,7 @@
"@babel/plugin-transform-modules-commonjs" "^7.6.0"
"@babel/plugin-transform-modules-systemjs" "^7.5.0"
"@babel/plugin-transform-modules-umd" "^7.2.0"
"@babel/plugin-transform-named-capturing-groups-regex" "^7.6.2"
"@babel/plugin-transform-named-capturing-groups-regex" "^7.6.3"
"@babel/plugin-transform-new-target" "^7.4.4"
"@babel/plugin-transform-object-super" "^7.5.5"
"@babel/plugin-transform-parameters" "^7.4.4"
@@ -983,7 +998,7 @@
"@babel/plugin-transform-template-literals" "^7.4.4"
"@babel/plugin-transform-typeof-symbol" "^7.2.0"
"@babel/plugin-transform-unicode-regex" "^7.6.2"
"@babel/types" "^7.6.0"
"@babel/types" "^7.6.3"
browserslist "^4.6.0"
core-js-compat "^3.1.1"
invariant "^2.2.2"
@@ -1065,6 +1080,17 @@
"@babel/plugin-transform-react-jsx-self" "^7.0.0"
"@babel/plugin-transform-react-jsx-source" "^7.0.0"

"@babel/preset-react@7.6.3":
version "7.6.3"
resolved "https://registry.yarnpkg.com/@babel/preset-react/-/preset-react-7.6.3.tgz#d5242c828322520205ae4eda5d4f4f618964e2f6"
integrity sha512-07yQhmkZmRAfwREYIQgW0HEwMY9GBJVuPY4Q12UC72AbfaawuupVWa8zQs2tlL+yun45Nv/1KreII/0PLfEsgA==
dependencies:
"@babel/helper-plugin-utils" "^7.0.0"
"@babel/plugin-transform-react-display-name" "^7.0.0"
"@babel/plugin-transform-react-jsx" "^7.0.0"
"@babel/plugin-transform-react-jsx-self" "^7.0.0"
"@babel/plugin-transform-react-jsx-source" "^7.0.0"

"@babel/preset-typescript@7.3.3":
version "7.3.3"
resolved "https://registry.yarnpkg.com/@babel/preset-typescript/-/preset-typescript-7.3.3.tgz#88669911053fa16b2b276ea2ede2ca603b3f307a"
@@ -1150,6 +1176,21 @@
globals "^11.1.0"
lodash "^4.17.13"

"@babel/traverse@^7.6.3":
version "7.6.3"
resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.6.3.tgz#66d7dba146b086703c0fb10dd588b7364cec47f9"
integrity sha512-unn7P4LGsijIxaAJo/wpoU11zN+2IaClkQAxcJWBNCMS6cmVh802IyLHNkAjQ0iYnRS3nnxk5O3fuXW28IMxTw==
dependencies:
"@babel/code-frame" "^7.5.5"
"@babel/generator" "^7.6.3"
"@babel/helper-function-name" "^7.1.0"
"@babel/helper-split-export-declaration" "^7.4.4"
"@babel/parser" "^7.6.3"
"@babel/types" "^7.6.3"
debug "^4.1.0"
globals "^11.1.0"
lodash "^4.17.13"

"@babel/types@^7.0.0", "@babel/types@^7.2.0", "@babel/types@^7.3.0", "@babel/types@^7.4.0", "@babel/types@^7.4.4", "@babel/types@^7.5.5":
version "7.5.5"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.5.5.tgz#97b9f728e182785909aa4ab56264f090a028d18a"
@@ -1168,6 +1209,15 @@
lodash "^4.17.13"
to-fast-properties "^2.0.0"

"@babel/types@^7.6.3":
version "7.6.3"
resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.6.3.tgz#3f07d96f854f98e2fbd45c64b0cb942d11e8ba09"
integrity sha512-CqbcpTxMcpuQTMhjI37ZHVgjBkysg5icREQIEZ0eG1yCNwg3oy+5AaLiOKmjsCj6nqOsa6Hf0ObjRVwokb7srA==
dependencies:
esutils "^2.0.2"
lodash "^4.17.13"
to-fast-properties "^2.0.0"

"@cnakazawa/watch@^1.0.3":
version "1.0.3"
resolved "https://registry.yarnpkg.com/@cnakazawa/watch/-/watch-1.0.3.tgz#099139eaec7ebf07a27c1786a3ff64f39464d2ef"
@@ -7978,10 +8028,10 @@ lines-and-columns@^1.1.6:
resolved "https://registry.yarnpkg.com/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00"
integrity sha1-HADHQ7QzzQpOgHWPe2SldEDZ/wA=

lint-staged@9.4.1:
version "9.4.1"
resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-9.4.1.tgz#60c0f85745bd398e6460aa7f5adb3cad3a2b862c"
integrity sha512-zFRbo1bAJEVf1m33paTTjDVfy2v3lICCqHfmQSgNoI+lWpi7HPG5y/R2Y7Whdce+FKxlZYs/U1sDSx8+nmQdDA==
lint-staged@9.4.2:
version "9.4.2"
resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-9.4.2.tgz#14cb577a9512f520691f8b5aefce6a8f7ead6c04"
integrity sha512-OFyGokJSWTn2M6vngnlLXjaHhi8n83VIZZ5/1Z26SULRUWgR3ITWpAEQC9Pnm3MC/EpCxlwts/mQWDHNji2+zA==
dependencies:
chalk "^2.4.2"
commander "^2.20.0"