require - Import ReactJS Component in browser as a Script -
i wrote component in reactjs renders tree
unable import directly browser , keep getting error:
uncaught error: module name "treecomponent" has not been loaded yet context: _. use require([]) http://requirejs.org/docs/errors.html#notloaded @ makeerror (require.js:5) @ object.o [as require] (require.js:5) @ requirejs (require.js:5) @ reactjs_returnreactjs.action:2192
babel preset react-app:
"babel": { "presets": [ "react-app" ] },
entry point build index.js:
export {default} './components/treecomponent';
can me find out wrong in build steps?
if export react component in treecomponent.js
way
export default treecomponent({ });
or this
exports.default = treecomponent;
you need import way
import { treecomponent } './components/treecomponent';
or can way too
import treecomponent './components/treecomponent/treecomponent';
Comments
Post a Comment