zsajjad / react-facebook-pixel

React JS wrapper for Facebook's Pixel
MIT License
236 stars 85 forks source link

commonjs export is not working in 0.1.1 #10

Closed rokoroku closed 6 years ago

rokoroku commented 6 years ago
const ReactPixel =  require('react-facebook-pixel');
ReactPixel.init('yourPixelIdGoesHere');

above code causes Uncaught TypeError: ReactPixel.init is not a function

Rather, we have to use default export now.

const ReactPixel =  require('react-facebook-pixel').default;
ReactPixel.init('yourPixelIdGoesHere');
bf commented 6 years ago

There is a babel / webpack plugin which changes this for you. I think it is either "add-module-exports" or "transform-es2015-modules-commonjs".

zsajjad commented 6 years ago

Hopefully, @bf's solution fixes this

rokoroku commented 6 years ago

Seriously? then you'd better change below description in the README.md.

2018-10-12 12 46 19