From 00ccda7a36e6aec7c9752c490a99919e677e5ba3 Mon Sep 17 00:00:00 2001 From: Jeremy Gayed Date: Sun, 19 Aug 2018 01:11:20 -0700 Subject: [PATCH] Upgrade to react-head v3 API --- example/src/Contact.js | 20 ++++++++++++-------- example/src/Home.js | 13 +++++++------ example/src/client.js | 7 +++++-- example/src/server.js | 22 ++++++++++++++-------- 4 files changed, 38 insertions(+), 24 deletions(-) diff --git a/example/src/Contact.js b/example/src/Contact.js index 69d072c..d72c486 100644 --- a/example/src/Contact.js +++ b/example/src/Contact.js @@ -1,23 +1,27 @@ +/* eslint-disable jsx-a11y/anchor-is-valid */ import React from 'react'; -import { HeadTag } from 'react-head'; -import { Link } from 'react-router-dom'; +import { Link, Title, Meta } from 'react-head'; +import { Link as RouterLink } from 'react-router-dom'; import logo from './react.svg'; import './Contact.css'; const Contact = () => (
- Contact | Example react-head App - - + Contact | Example react-head App + +
logo

react-head contact us page

- View the example code in src/Contact.js. Note that this works isomorphically. + View the example code in src/Contact.js. Note that this works + isomorphically.

-

Click the example home page below to see how the Header tags will update

- Home +

+ Click the example home page below to see how the Header tags will update +

+ Home
  • Docs diff --git a/example/src/Home.js b/example/src/Home.js index 3b4908f..6eaf971 100644 --- a/example/src/Home.js +++ b/example/src/Home.js @@ -1,17 +1,18 @@ +/* eslint-disable jsx-a11y/anchor-is-valid */ import React from 'react'; -import { HeadTag, Style } from 'react-head'; -import { Link } from 'react-router-dom'; +import { Link, Meta, Title, Style } from 'react-head'; +import { Link as RouterLink } from 'react-router-dom'; import logo from './react.svg'; import './Home.css'; const Home = () => (
    - Home | Example react-head App + Home | Example react-head App - - + +
    logo

    react-head example

    @@ -24,7 +25,7 @@ const Home = () => ( Click the example contact page below to see how the Header tags will update

    - Contact Page + Contact Page
    • Docs diff --git a/example/src/client.js b/example/src/client.js index 0f175e7..bafeb11 100644 --- a/example/src/client.js +++ b/example/src/client.js @@ -1,11 +1,14 @@ -import App from './App'; import BrowserRouter from 'react-router-dom/BrowserRouter'; import React from 'react'; import { hydrate } from 'react-dom'; +import { HeadProvider } from 'react-head'; +import App from './App'; hydrate( - + + + , document.getElementById('root') ); diff --git a/example/src/server.js b/example/src/server.js index fe6a45a..adc71d6 100644 --- a/example/src/server.js +++ b/example/src/server.js @@ -2,10 +2,10 @@ import React from 'react'; import { StaticRouter } from 'react-router-dom'; import express from 'express'; import { renderToString } from 'react-dom/server'; -import { HeadCollector } from 'react-head'; +import { HeadProvider } from 'react-head'; import App from './App'; -const assets = require(process.env.RAZZLE_ASSETS_MANIFEST); +const assets = require(process.env.RAZZLE_ASSETS_MANIFEST); // eslint-disable-line const server = express(); server @@ -16,9 +16,9 @@ server const headTags = []; const markup = renderToString( - + - + ); @@ -32,10 +32,16 @@ server - ${assets.client.css ? `` : ''} - ${process.env.NODE_ENV === 'production' - ? `` - : ``} + ${ + assets.client.css + ? `` + : '' + } + ${ + process.env.NODE_ENV === 'production' + ? `` + : `` + } ${renderToString(headTags)}