I want to create a utils.js that contains all of my utility functions, which are used by many of my React components.
I try to export and import a Utilities class into my React component like this:
// utils. js
export default class Utilities;
// myComponent.es6.jsx
import someFunction from 'Utilities';
I receive errors like these:
Uncaught ReferenceError: require is not defined(anonymous function)
Uncaught ReferenceError: exports is not defined
How do I set up a separate utilities page that can then be imported into my React components?
I'm baffled -- thanks for any help you can provide!
your answer could be here. Basically, I believe it's because import export and require are not yet fully compatible with Rails and all browsers. That's why in most applications they use Babel transpiler or common JS stuff. Let me know if that helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With