8000 Universal rendering issue on ^1.5.0 · Issue #132 · i18next/react-i18next · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Universal rendering issue on ^1.5.0 #132

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
duvillierA opened this issue Jun 17, 2016 · 3 comments
Closed

Universal rendering issue on ^1.5.0 #132

duvillierA opened this issue Jun 17, 2016 · 3 comments

Comments

@duvillierA
Copy link
duvillierA commented Jun 17, 2016

Hi,

On react-i18next >= 1.5.0, universal rendering is broken.
Error: Invariant Violation: React DOM tree root should always have a node reference.

Related to this issue react issue, this line might be the cause.

A rerender occur on server-side because of a setState inside the componentWillMount hook

My server side setup :

  match({ routes, location}, (error, redirectLocation, renderProps) => {
    if (error) {
      res.status(500).send(error.message)
    } else if (redirectLocation) {
      res.redirect(302, redirectLocation.pathname + redirectLocation.search)
    } else if (renderProps) {
      loadNamespaces(Object.assign({}, renderProps, {i18n}))
      .then(() => {
        const isNotFound = renderProps.routes.find((route) => {
          return route.status === 404
        })
        const locale = req.language
        const locales = res.locals.locales
        const component = (
            <I18nextProvider i18n={req.i18n}>
              <RouterContext
                {...renderProps}
              />
            </I18nextProvider>
        )

        res.status(isNotFound ? 404 :  200).send('<!doctype html>\n' +
          renderToStaticMarkup(<Html assets={webpack_isomorphic_tools.assets()}
                                     component={component} />))
      })
    } else {
      res.status(404).send('Not found')
    }
  })
 // html.js
  render()
  {
    const { assets, component} = this.props
    // throw error below
    const content = component ? ReactDOM.renderToString(component) : ''
}

Do you have any clue?

Thanks

@duvillierA duvillierA changed the title Universal rendering Universal rendering issue on ^1.5.0 Jun 17, 2016
@jamuhl
Copy link
Member
jamuhl commented Jun 17, 2016

could you please try with react-i18next@1.5.2?!?

@duvillierA
Copy link
Author

@jamuhl Issue fixed 👍

@jamuhl
Copy link
Member
jamuhl commented Jun 17, 2016

perfect

@jamuhl jamuhl closed this as completed Jun 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0