React-helmet: Can not call renderStatic on server side when using with jsdom

Created on 13 Aug 2017  路  4Comments  路  Source: nfl/react-helmet

Im using jsdom-global to provide global DOM environment, but our helmet thinks it's in a browser and throw an error You may only call rewind() on the server. Call peek() to read the current state. every time I call renderStatic.

Can we have an option to ignore the side effect and just process as normal?

Most helpful comment

Thanks @namnm for the hint - it helped!
For other folks - call Helmet.canUseDOM = false; as soon as you import / require Helmet, otherwise you may get inconsistent results from Helmet.renderStatic()

All 4 comments

I figured out that I need to set the canUseDom to false. Then it will work fine. I think we should add some document about this field as well?

You are probably referring to canUseDOM instead.

Yeah, I have already figured it out, and ask if we can have a better documentation about that field then.

Thanks @namnm for the hint - it helped!
For other folks - call Helmet.canUseDOM = false; as soon as you import / require Helmet, otherwise you may get inconsistent results from Helmet.renderStatic()

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bassarisse picture bassarisse  路  3Comments

brianespinosa picture brianespinosa  路  3Comments

MiguelMachado-dev picture MiguelMachado-dev  路  4Comments

mattecapu picture mattecapu  路  4Comments

sneridagh picture sneridagh  路  4Comments