jeffling / wallaby-webpack

webpack preprocessor for wallabyjs
25 stars 8 forks source link

Importing react throw error #12

Closed eskimoblood closed 9 years ago

eskimoblood commented 9 years ago

When I import react into module wallaby throws this error. I'm using the same config as the Wallaby.js with React + Webpack + ES6example

TypeError: 'undefined' is not a function (evaluating 'ReactElementValidator.createElement.bind(
      null,
      type
    )')
ArtemGovorov commented 9 years ago

The most likely reason is that Function.prototype.bind polyfill is not loaded. If you have the same config as in the repo that you've referenced, please double check that this module is installed and has this file:

`{pattern: 'node_modules/react-tools/src/test/phantomjs-shims.js', instrument: false},`

If you have some other file with Function.prototype.bind polyfill, you may just reference it instead of installing react-tools module, for example like is done in this sample.

The reason you need to do this is because PhantomJs 1.x doesn't support Function.prototype.bind. PhantomJs 2 doesn't have this issue and wallaby.js supports it, so you also consider using it and then you will not need the polyfill.

Please let me know if it fixes the issue for you.

eskimoblood commented 9 years ago

Installing react-tools fixed it. thanks