1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Apollo Example: Fix duplicate head tags (#2362)

This commit is contained in:
Thomas Preusse 2017-06-28 19:07:21 +02:00 committed by Tim Neutkens
parent 19b6cca44b
commit 3be175b466
2 changed files with 8 additions and 0 deletions

View file

@ -1,6 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import { ApolloProvider, getDataFromTree } from 'react-apollo'
import Head from 'next/head'
import initApollo from './initApollo'
import initRedux from './initRedux'
@ -37,6 +38,9 @@ export default ComposedComponent => {
</ApolloProvider>
)
await getDataFromTree(app)
// getDataFromTree does not call componentWillUnmount
// head side effect therefore need to be cleared manually
Head.rewind()
// Extract query data from the store
const state = redux.getState()

View file

@ -1,6 +1,7 @@
import React from 'react'
import PropTypes from 'prop-types'
import { ApolloProvider, getDataFromTree } from 'react-apollo'
import Head from 'next/head'
import initApollo from './initApollo'
export default ComposedComponent => {
@ -33,6 +34,9 @@ export default ComposedComponent => {
</ApolloProvider>
)
await getDataFromTree(app)
// getDataFromTree does not call componentWillUnmount
// head side effect therefore need to be cleared manually
Head.rewind()
// Extract query data from the Apollo's store
const state = apollo.getInitialState()