From f1c61d1c248db30532c1c1ecdafe266d8cc363ed Mon Sep 17 00:00:00 2001 From: ZauberNerd Date: Thu, 24 Oct 2019 11:18:10 +0200 Subject: [PATCH] fix: switch to react-helmet-async --- README.md | 2 +- packages/graphql/package.json | 4 +-- packages/hops/package.json | 4 +-- packages/jest-preset/package.json | 4 +-- packages/pwa/README.md | 2 +- packages/react/README.md | 6 ++-- packages/react/package.json | 4 +-- packages/spec/integration/lambda/package.json | 2 +- packages/spec/integration/pwa/index.js | 2 +- packages/template-graphql/package.json | 2 +- packages/template-graphql/src/home/index.js | 2 +- .../src/home/spec/index.spec.js | 17 +++++++++-- packages/template-react/package.json | 2 +- packages/template-react/src/home/index.js | 2 +- .../src/home/spec/index.spec.js | 11 ++++++- packages/template-redux/package.json | 2 +- packages/template-redux/src/home/index.js | 2 +- .../src/home/spec/index.spec.js | 11 ++++++- yarn.lock | 30 ++++++++----------- 19 files changed, 68 insertions(+), 43 deletions(-) diff --git a/README.md b/README.md index b05282c44..0cc232c02 100644 --- a/README.md +++ b/README.md @@ -818,7 +818,7 @@ Now you can `import`/`require` your web app manifest and render a `` tag ```javascript import { render } from 'hops'; import React from 'react'; -import Helmet from 'react-helmet'; +import { Helmet } from 'react-helmet-async'; import manifest from './manifest.webmanifest'; export default render( diff --git a/packages/graphql/package.json b/packages/graphql/package.json index 2646154a4..a324f517c 100644 --- a/packages/graphql/package.json +++ b/packages/graphql/package.json @@ -39,7 +39,7 @@ "react": "^16.8.0", "react-apollo": "^3.1.0", "react-dom": "^16.8.0", - "react-helmet": "^5.2.0", + "react-helmet-async": "^1.0.4", "react-router-dom": "^5.1.0" }, "devDependencies": { @@ -47,7 +47,7 @@ "react": "^16.10.2", "react-apollo": "^3.1.2", "react-dom": "^16.10.2", - "react-helmet": "^5.2.1", + "react-helmet-async": "^1.0.4", "react-router-dom": "^5.1.2" }, "homepage": "https://github.com/xing/hops/tree/master/packages/graphql#readme" diff --git a/packages/hops/package.json b/packages/hops/package.json index 81d72f1b6..7b7cb76df 100644 --- a/packages/hops/package.json +++ b/packages/hops/package.json @@ -38,7 +38,7 @@ "peerDependencies": { "react": "^16.8.0", "react-dom": "^16.8.0", - "react-helmet": "^5.2.0", + "react-helmet-async": "^1.0.4", "react-router-dom": "^5.1.0" }, "devDependencies": { @@ -46,7 +46,7 @@ "@types/react-router-dom": "*", "react": "^16.10.2", "react-dom": "^16.10.2", - "react-helmet": "^5.2.1", + "react-helmet-async": "^1.0.4", "react-router-dom": "^5.1.2" } } diff --git a/packages/jest-preset/package.json b/packages/jest-preset/package.json index 77ccbc73c..a8184ce16 100644 --- a/packages/jest-preset/package.json +++ b/packages/jest-preset/package.json @@ -38,14 +38,14 @@ "jest": "^24.9.0", "react": "^16.8.0", "react-dom": "^16.8.0", - "react-helmet": "^5.2.0", + "react-helmet-async": "^1.0.4", "react-router-dom": "^5.1.0" }, "devDependencies": { "jest": "^24.9.0", "react": "^16.10.2", "react-dom": "^16.10.2", - "react-helmet": "^5.2.1", + "react-helmet-async": "^1.0.4", "react-router-dom": "^5.1.2" }, "homepage": "https://github.com/xing/hops/tree/master/packages/jest-preset#readme" diff --git a/packages/pwa/README.md b/packages/pwa/README.md index ae0e355ed..bc0076984 100644 --- a/packages/pwa/README.md +++ b/packages/pwa/README.md @@ -20,7 +20,7 @@ If you don't already have an existing Hops project read this section [on how to #### Web App Manifest -When you `import` / `require` a web app manifest in your application code you will get an URL to the web app manifet which you can, for example, render in a `` element via [Helmet](https://github.com/nfl/react-helmet). +When you `import` / `require` a web app manifest in your application code you will get an URL to the web app manifet which you can, for example, render in a `` element via [React Helmet Async](https://github.com/staylor/react-helmet-async). ```javascript import manifest from './manifest.webmanifest'; diff --git a/packages/react/README.md b/packages/react/README.md index 46a4acba7..40e887b26 100644 --- a/packages/react/README.md +++ b/packages/react/README.md @@ -4,14 +4,14 @@ **Please see the [main Hops Readme](https://github.com/xing/hops/blob/master/README.md) for general information and a Getting Started Guide.** -This is a [preset for Hops](https://github.com/xing/hops/tree/master#presets) that enables React, JSX, React-Helmet and React-Router support in Hops applications. +This is a [preset for Hops](https://github.com/xing/hops/tree/master#presets) that enables React, JSX, React-Helmet Async and React-Router support in Hops applications. ### Installation -Add this preset and its peer dependencies `react`, `react-dom`, `react-helmet` and `react-router-dom` to your existing Hops React project: +Add this preset and its peer dependencies `react`, `react-dom`, `react-helmet-async` and `react-router-dom` to your existing Hops React project: ```bash -npm install --save hops-react react react-dom react-helmet react-router-dom +npm install --save hops-react react react-dom react-helmet-async react-router-dom ``` If you don't already have an existing Hops project read this section [on how to set up your first Hops project.](https://github.com/xing/hops/tree/master#quick-start) diff --git a/packages/react/package.json b/packages/react/package.json index b89ea5bcc..b097da7a4 100644 --- a/packages/react/package.json +++ b/packages/react/package.json @@ -28,13 +28,13 @@ "peerDependencies": { "react": "^16.8.0", "react-dom": "^16.8.0", - "react-helmet": "^5.2.0", + "react-helmet-async": "^1.0.4", "react-router-dom": "^5.1.0" }, "devDependencies": { "react": "^16.10.2", "react-dom": "^16.10.2", - "react-helmet": "^5.2.1", + "react-helmet-async": "^1.0.4", "react-router-dom": "^5.1.2" }, "homepage": "https://github.com/xing/hops/tree/master/packages/react#readme" diff --git a/packages/spec/integration/lambda/package.json b/packages/spec/integration/lambda/package.json index 40ed649ba..af0a19488 100644 --- a/packages/spec/integration/lambda/package.json +++ b/packages/spec/integration/lambda/package.json @@ -25,7 +25,7 @@ "hops-lambda": "*", "react": "*", "react-dom": "*", - "react-helmet": "*", + "react-helmet-async": "*", "react-router-dom": "*" } } diff --git a/packages/spec/integration/pwa/index.js b/packages/spec/integration/pwa/index.js index 1ddd17627..0ad4a0c35 100644 --- a/packages/spec/integration/pwa/index.js +++ b/packages/spec/integration/pwa/index.js @@ -1,7 +1,7 @@ import installServiceWorker from 'hops-pwa'; import { render } from 'hops'; import React from 'react'; -import Helmet from 'react-helmet'; +import { Helmet } from 'react-helmet-async'; import manifest from './manifest.webmanifest'; diff --git a/packages/template-graphql/package.json b/packages/template-graphql/package.json index 07d374626..3d78649b3 100644 --- a/packages/template-graphql/package.json +++ b/packages/template-graphql/package.json @@ -24,7 +24,7 @@ "react": "^16.10.2", "react-apollo": "^3.1.2", "react-dom": "^16.10.2", - "react-helmet": "^5.2.1", + "react-helmet-async": "^1.0.4", "react-router-dom": "^5.1.2" }, "devDependencies": { diff --git a/packages/template-graphql/src/home/index.js b/packages/template-graphql/src/home/index.js index 4e8a4ed3c..80bbd1c0c 100644 --- a/packages/template-graphql/src/home/index.js +++ b/packages/template-graphql/src/home/index.js @@ -1,6 +1,6 @@ import React from 'react'; import { graphql } from 'react-apollo'; -import Helmet from 'react-helmet'; +import { Helmet } from 'react-helmet-async'; import query from './commits.gql'; import styles from './styles.css'; diff --git a/packages/template-graphql/src/home/spec/index.spec.js b/packages/template-graphql/src/home/spec/index.spec.js index 8d64080f2..28cb85015 100644 --- a/packages/template-graphql/src/home/spec/index.spec.js +++ b/packages/template-graphql/src/home/spec/index.spec.js @@ -1,9 +1,18 @@ import React from 'react'; import renderer from 'react-test-renderer'; +import { HelmetProvider } from 'react-helmet-async'; import { Home } from '../'; +HelmetProvider.canUseDOM = false; + it('renders loading state correctly', () => { - const tree = renderer.create().toJSON(); + const tree = renderer + .create( + + + + ) + .toJSON(); expect(tree).toMatchSnapshot(); }); @@ -35,6 +44,10 @@ it('renders loaded state correctly', () => { }, }, }; - const tree = renderer.create(); + const tree = renderer.create( + + + + ); expect(tree).toMatchSnapshot(); }); diff --git a/packages/template-react/package.json b/packages/template-react/package.json index 6f707f4e0..19074f84d 100644 --- a/packages/template-react/package.json +++ b/packages/template-react/package.json @@ -21,7 +21,7 @@ "prop-types": "^15.7.2", "react": "^16.10.2", "react-dom": "^16.10.2", - "react-helmet": "^5.2.1", + "react-helmet-async": "^1.0.4", "react-router-dom": "^5.1.2" }, "devDependencies": { diff --git a/packages/template-react/src/home/index.js b/packages/template-react/src/home/index.js index b91171733..26d46a3b2 100644 --- a/packages/template-react/src/home/index.js +++ b/packages/template-react/src/home/index.js @@ -1,5 +1,5 @@ import React from 'react'; -import Helmet from 'react-helmet'; +import { Helmet } from 'react-helmet-async'; import styles from './styles.css'; export default function Home() { diff --git a/packages/template-react/src/home/spec/index.spec.js b/packages/template-react/src/home/spec/index.spec.js index 6ccf9dcfd..e05400689 100644 --- a/packages/template-react/src/home/spec/index.spec.js +++ b/packages/template-react/src/home/spec/index.spec.js @@ -1,8 +1,17 @@ import React from 'react'; import renderer from 'react-test-renderer'; +import { HelmetProvider } from 'react-helmet-async'; import Home from '../'; +HelmetProvider.canUseDOM = false; + it('renders correctly', () => { - const tree = renderer.create().toJSON(); + const tree = renderer + .create( + + + + ) + .toJSON(); expect(tree).toMatchSnapshot(); }); diff --git a/packages/template-redux/package.json b/packages/template-redux/package.json index 3739c1c49..d1716da09 100644 --- a/packages/template-redux/package.json +++ b/packages/template-redux/package.json @@ -22,7 +22,7 @@ "prop-types": "^15.7.2", "react": "^16.10.2", "react-dom": "^16.10.2", - "react-helmet": "^5.2.1", + "react-helmet-async": "^1.0.4", "react-redux": "^7.1.1", "react-router-dom": "^5.1.2", "redux": "^4.0.4", diff --git a/packages/template-redux/src/home/index.js b/packages/template-redux/src/home/index.js index b91171733..26d46a3b2 100644 --- a/packages/template-redux/src/home/index.js +++ b/packages/template-redux/src/home/index.js @@ -1,5 +1,5 @@ import React from 'react'; -import Helmet from 'react-helmet'; +import { Helmet } from 'react-helmet-async'; import styles from './styles.css'; export default function Home() { diff --git a/packages/template-redux/src/home/spec/index.spec.js b/packages/template-redux/src/home/spec/index.spec.js index 6ccf9dcfd..e05400689 100644 --- a/packages/template-redux/src/home/spec/index.spec.js +++ b/packages/template-redux/src/home/spec/index.spec.js @@ -1,8 +1,17 @@ import React from 'react'; import renderer from 'react-test-renderer'; +import { HelmetProvider } from 'react-helmet-async'; import Home from '../'; +HelmetProvider.canUseDOM = false; + it('renders correctly', () => { - const tree = renderer.create().toJSON(); + const tree = renderer + .create( + + + + ) + .toJSON(); expect(tree).toMatchSnapshot(); }); diff --git a/yarn.lock b/yarn.lock index 51f4af90a..1f0611eee 100644 --- a/yarn.lock +++ b/yarn.lock @@ -758,7 +758,7 @@ "@babel/plugin-transform-react-jsx-self" "^7.0.0" "@babel/plugin-transform-react-jsx-source" "^7.0.0" -"@babel/runtime@^7.1.2", "@babel/runtime@^7.4.0", "@babel/runtime@^7.5.5", "@babel/runtime@^7.6.2": +"@babel/runtime@^7.1.2", "@babel/runtime@^7.3.4", "@babel/runtime@^7.4.0", "@babel/runtime@^7.5.5", "@babel/runtime@^7.6.2": version "7.6.3" resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.6.3.tgz#935122c74c73d2240cafd32ddb5fc2a6cd35cf1f" integrity sha512-kq6anf9JGjW8Nt5rYfEuGRaEAaH1mkv3Bbu6rYvLOpPh/RusSJXuKPEAoZ7L7gybZkchE8+NV5g9vKF4AGAtsA== @@ -10846,20 +10846,21 @@ react-dom@^16.10.2: prop-types "^15.6.2" scheduler "^0.16.2" -react-fast-compare@^2.0.2: +react-fast-compare@^2.0.4: version "2.0.4" resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-2.0.4.tgz#e84b4d455b0fec113e0402c329352715196f81f9" integrity sha512-suNP+J1VU1MWFKcyt7RtjiSWUjvidmQSlqu+eHslq+342xCbGTYmC0mEhPCOHxlW0CywylOC1u2DFAT+bv4dBw== -react-helmet@^5.2.1: - version "5.2.1" - resolved "https://registry.yarnpkg.com/react-helmet/-/react-helmet-5.2.1.tgz#16a7192fdd09951f8e0fe22ffccbf9bb3e591ffa" - integrity sha512-CnwD822LU8NDBnjCpZ4ySh8L6HYyngViTZLfBBb3NjtrpN8m49clH8hidHouq20I51Y6TpCTISCBbqiY5GamwA== +react-helmet-async@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/react-helmet-async/-/react-helmet-async-1.0.4.tgz#079ef10b7fefcaee6240fefd150711e62463cc97" + integrity sha512-KTGHE9sz8N7+fCkZ2a3vzXH9eIkiTNhL2NhKR7XzzQl3WsGlCHh76arauJUIiGdfhjeMp7DY7PkASAmYFXeJYg== dependencies: - object-assign "^4.1.1" - prop-types "^15.5.4" - react-fast-compare "^2.0.2" - react-side-effect "^1.1.0" + "@babel/runtime" "^7.3.4" + invariant "^2.2.4" + prop-types "^15.7.2" + react-fast-compare "^2.0.4" + shallowequal "^1.1.0" react-is@^16.6.0, react-is@^16.7.0, react-is@^16.8.1, react-is@^16.8.4, react-is@^16.8.6, react-is@^16.9.0: version "16.10.2" @@ -10907,13 +10908,6 @@ react-router@5.1.2: tiny-invariant "^1.0.2" tiny-warning "^1.0.0" -react-side-effect@^1.1.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/react-side-effect/-/react-side-effect-1.2.0.tgz#0e940c78faba0c73b9b0eba9cd3dda8dfb7e7dae" - integrity sha512-v1ht1aHg5k/thv56DRcjw+WtojuuDHFUgGfc+bFHOWsF4ZK6C2V57DO0Or0GPsg6+LSTE0M6Ry/gfzhzSwbc5w== - dependencies: - shallowequal "^1.0.1" - react-test-renderer@^16.10.2: version "16.10.2" resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.10.2.tgz#4d8492f8678c9b43b721a7d79ed0840fdae7c518" @@ -11669,7 +11663,7 @@ sha.js@^2.4.0, sha.js@^2.4.11, sha.js@^2.4.8: inherits "^2.0.1" safe-buffer "^5.0.1" -shallowequal@^1.0.1: +shallowequal@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/shallowequal/-/shallowequal-1.1.0.tgz#188d521de95b9087404fd4dcb68b13df0ae4e7f8" integrity sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ==