podio / requirejs-react-jsx

A RequireJS plugin for loading jsx in development and compiling (with r.js). Supports bundling and 1:1 source maps in development and production.
MIT License
104 stars 20 forks source link

how to call another jsx in jsx? #19

Open eungchang opened 8 years ago

eungchang commented 8 years ago

i am user of spring boot. i tried to call test1.jsx in test2.jsx .

and i met this error message which from test2.jsx

`Uncaught SyntaxError: /test2.jsx: Unexpected token (9:8) 7 | function App() { 8 | this.AppView = React.createClass({

9 | var dd = Test1.App2(); | ^ 10 | render: function () { 11 | return ( 12 |

`

this is my main.js. almost same your example.

`require.config({

paths: {
    react:'lib/react/react',
    reactDOM: 'lib/react/react-dom',
    babel: 'lib/require-react-jsx/babel-5.8.34.min',
    jsx: 'lib/require-react-jsx/jsx',   
    text: 'lib/require-react-jsx/text',
    jquery: 'lib/jquery-2.2.0'  
},

shim: {
    "react": {
        "exports": "React"
    }
},

config: {
    babel: {
        sourceMaps: "inline", // One of [false, 'inline', 'both']. See https://babeljs.io/docs/usage/options/
        fileExtension: ".jsx" // Can be set to anything, like .es6 or .js. Defaults to .jsx
    }
}

});

require(['jsx!test2'], function(App){

  var app = new App();
  app.init();

});`

and this is my test1.jsx

`define(function(require){

var React = require('react'); var ReactDOM = require('reactDOM');

function App2() { this.trouble = React.createClass({ render: function () { return (

how to call here?

    );
  }
});

}

App2.prototype.init = function () { ReactDOM.render( ) };

return App2;

});`

this is my test2.jsx

`define(function(require){

var React = require('react'); var ReactDOM = require('reactDOM'); var Test1 = require('jsx!test1');

function App() { this.AppView = React.createClass({ var dd = Test1.App2(); render: function () { return (

Hello, React!

```
);

} });


  }

  App.prototype.init = function () {
    ReactDOM.render(<this.AppView />, 

document.getElementById("testRequire"));



  };

  return App;

});`

so, i don't know how to call 

could give me a hint for that?
Munter commented 8 years ago

As the error clearly points out you have a syntax error on line 9. You cannot declare a variable inside an object literal.