require - Import ReactJS Component in browser as a Script -


i wrote component in reactjs renders tree

component sample 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:

enter image description here

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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -