1

I have a JSX file like this:

var Home = React.createClass({
    render: function() {
        return (
<Test>
...
var Test = React.createClass({
    render: function() {
...

module.exports = Home;

But I cant manage that both functions load, I guess I have to add Test to module.exports, but I couldn't find a method that worked.

2 Answers 2

2

If you require("home.jsx") it will automaticaly load and render your Test component inside Home.

It would be better to separate those components in defferent files, that will help you to manage components when your app will be too large.

test.jsx

module.exports = React.createClass({
  render: function() {
    return <div>Test</div>
  }
})

home.jsx

var Test = require('./test.jsx');

module.exports = React.createClass({
   render: function() {
      return <div>
        <Test>
      </div>
   }
})

Of course you are also able to do something like @Mukesh Sharma answer.

Thanks

Sign up to request clarification or add additional context in comments.

Comments

0

Hope it helps you.

var Home = React.createClass({
   render: function() {
      return (
<Test>
...
var Test = React.createClass({
   render: function() {
...

module.exports = {
  "Home": Home,
  "Test": Test
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.