react-helmet: Broken export when using Webpack 2 (React.createElement: type should not be null)
In 3.1.0 the export is not broken: typeof require('react-helmet') === 'function'.
In 3.2.0 it is broken: typeof require('react-helmet') === 'object'.
The error is “Warning: React.createElement: type should not be null, undefined, boolean, or number. It should be a string (for DOM elements) or a ReactClass (for composite components). Check the render method of Layout.”
The cause is that v3.2.x of ReactHelmet is { default: function ReactHelmet() {} } when imported in Webpack 2.
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 11
- Comments: 25 (12 by maintainers)
Just spent an entire day with @bonitis trying to track down an issue that has this at its root. Good find, @halt-hammerzeit!
+1
@mbifulco @Bonitis Yeah, this was a nontrivial one. Took me almost half an hour.
Fuck yeah, let do a circle
jerklikeApologies for the headache on this. This is now fixed in v3.2.2
@cwelch5 The issue is that the ES6 compiled version that is in
esfolder actually sticks to the standards forexport default.There are a few articles about this
Misunderstanding ES6 Modules, Upgrading Babel, Tears, and a Solution
ES6 Modules
I suggest we follow how
reduxandreact-routerdo their exports without usingexport defaulton the entry files.for example redux is
and you import in your project as
So then you would have to do
import { Helmet } from 'react-helmet';Or i can just compile the
esversion with commonjs exports not making itES6Let me know either way and I can do a pull request in a bit.
This shouldn’t effect people using the ES5 version
@doctyper perhaps it would be best to remove
moduleandjsnext:mainfromhttps://github.com/nfl/react-helmet/blob/master/package.json#L6-L7
Then wait for a major release to implement it
@cwelch5 3.1.0 work fine. issue only for ^3.2.0. It would be nice to keep it as it is without special babel configs since it will be constant repeating issue