reactjs - Change script type to "text/babel" using requireJS -


i using requirejs load react components getting error "uncaught syntaxerror: unexpected token <" because script type file "text/javascript" instead of "text/babel". solve have tried set scripttype explained requirejs docs , explained in question, i'm unable working or find example of how make work.

requireconfig.js:

requirejs.config({     baseurl: 'scripts/',     paths:     {         jquery: 'jquery-1.9.0',         react: 'libs/build/react',         reactdom: 'libs/build/react-dom',         browser: '//cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min',         inputwindow: 'inputwindow/inputwindow'     },     scripttype: {         'inputwindow': "text/babel"      } });  define(function (require) {     var inputwindow = require('inputwindow');      inputwindow.initialize();   }); 

inputwindow.js:

define(function(require){      var react = require('react');     var reactdom = require('reactdom');      var inputwindow = react.createclass({          render: function(){             return(<div>                 {this.props.message}             </div>)              }      });      function initialize(){         reactdom.render(<inputwindow message="hello world!"/>, document.getelementbyid('inputwindowdiv'))     }      return {         initialize: initialize,     } }) 

when configure requireconfig.js section

scripttype:{     'inputwindow':'text/babel' } 

then file inputwindow.js loaded index.html tag

type="[object object]" 

until requirejs times out.

screen capture of inputwindow.js loaded type=[object object]

instead of

scripttype: {     'inputwindow': "text/babel" } 

try

scripttype: 'text/babel' 

it should work. right you're trying stringify object no wonder doesn't work. ;)


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -