1

Is it possible to store some React templates in properties of one global variable? I mean that I want to create two child templates:

app.templates.CommonProducts = React.createClass(/* any render, etc */);

and

app.templates.DiscountProducts = React.createClass(/* any render, etc */);

How can I get these templates in "parent" template? What tag names (CommonProducts, DiscountProducts) should look like?

app.templates.Products = React.createClass({
    render: function() {
        return (
            <div>
                <CommonProducts></CommonProducts>
                <DiscountProducts></DiscountProducts>
            </div>
        );
    }
});

1 Answer 1

1

It is called Namespaced Components,

app.templates.Products = React.createClass({
  render: function() {
    return (
      <div>
        <app.templates.DiscountProducts></app.templates.DiscountProducts>
        <app.templates.CommonProducts></app.templates.CommonProducts>
      </div>
    );
  }
});

Example

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

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.