aaronshaf / react-toggle

Elegant, accessible toggle component for React. Also a glorified checkbox.
http://aaronshaf.github.io/react-toggle/
MIT License
949 stars 158 forks source link

CommonJS import error #97

Open hugoalvarado opened 7 years ago

hugoalvarado commented 7 years ago

Hello,

I followed the guide and attempted to use the CommonJS import: const Toggle = require('react-toggle')

And got these 2 errors:

Warning: React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: object.

Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. Check the render method of StatelessComponent.

Which could be resolved by changing the import: const Toggle = require('react-toggle').default or adding module.exports = Toggle;

to index.js.

benpptung commented 7 years ago

+1