+
Skip to content
This repository was archived by the owner on Nov 21, 2017. It is now read-only.
This repository was archived by the owner on Nov 21, 2017. It is now read-only.

Is there a JSX equivalent to this.props.children? #13

@MattMcFarland

Description

@MattMcFarland

Hi,

I've switched from React to Mithril, and MSX has been really great. With JSX, you can invoke {this.props.children} to render child components that can be between an opening and closing tag.

<MyComponent>
    <MyHeader>{this.props.heading}</MyHeader>
    <SomeContent>
        <AnotherCustomComponent/>
        <AnotherComponent>
            <ReallyNestedNow/>
        </AnotherComponent>
    </SomeContent>
</MyComponent>

So how does it work?

SomeContent () {
    render () {
        <div>
            <header>
                <h4>Lorem Ipsum</h4>
            </header>
            {this.props.children} 
            // In this example, it would render every component inbetween the opening and closing <SomeContent> tag as seen above.
            <footer>Lalalalalal</footer>
        </div>
    }
}

This makes working with JSX very easy, especially when running into situations where it makes more sense to enclose a component this way.

I'm running into a sitaution with Mithril where I want to do this, but it is not working. Is there any alternative?

Thanks!!
Matt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载