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)

Most upvoted comments

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.

CLICK HERE

Fuck yeah, let do a circle jerk like

Apologies 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 es folder actually sticks to the standards for export default.

There are a few articles about this

Misunderstanding ES6 Modules, Upgrading Babel, Tears, and a Solution

ES6 Modules

I suggest we follow how redux and react-router do their exports without using export default on the entry files.

for example redux is

export {
  createStore,
  combineReducers,
  bindActionCreators,
  applyMiddleware,
  compose
}

and you import in your project as

import {createStore} from 'redux'

So then you would have to do import { Helmet } from 'react-helmet';

Or i can just compile the es version with commonjs exports not making it ES6

Let 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 module and jsnext:main from

https://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