Quantcast
Channel: Active questions tagged require - Stack Overflow
Viewing all articles
Browse latest Browse all 166

importing and exporting modules in react

$
0
0

I'm working in a React.js project which I need to import some JavaScript in others, and some others I have to export it.

For example I have A.js which needs some library:

var EventEmitter = require('EventEmitter');var React = require('react');//some code here//some function definitionvar fun = function(){...}module.exports = fun;

And then I have another B.js which needs not only libraries but also my own JavaScript. For example B.js (I suppose both in the same folder):

var fun = require('./B.js');var React = require('react');//some other code here

I tried using the library requirejs and also try something with npm and nodejs but I'm not sure how it works.I'm using the flux-chat example


Viewing all articles
Browse latest Browse all 166

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>