I have an application (built in Rails) that renders some markup in the back-end, which I would then like to "enhance" with additional functionality in the front-end, using ReactJS.
Rendering the content looks something like this:
<%= react_component :TestComponent do %>
<div class="foo">
Here's some content.
</div>
<% end %>
This call creates a wrapper div with some data-
attributes that react_ujs then captures to instantiate React components. What I'm failing to do is find a way (short of using jquery to do some mildly crazy tricks) to get the contents of this mount element (so, the inner div with the class 'foo', and its contents) in my React component, so that I can then include it in my JSX.
React.createClass({
render: function() {
return (
<div className="my-component">
{ mount point contents here! }
</div>
);
}
});
The behavior is what's described in AngularJS terms as a "transclude".
Any ideas how this behavior can be achieved with ReactJS? I've received some pointers towards this.props.children
, but this doesn't seem to yield the results I need, and will be undefined
even then the mount element has content.