1

I'm using react_rails to render react components inside of a slim template in a Ruby on Rails application. Is there a way to pass children to a React component, where the children are rendered server-side in slim?

Here is what I would ideally like to have:

<MyComponent>
  <p>my custom content</p>
</MyComponent>

Where the content comes from the template itself, something like this:

= react_component 'MyComponent' do 
  p my custom content

Is this possible? If so what's the best way to pass children to a react_component?

GSto
  • 41,512
  • 37
  • 133
  • 184

1 Answers1

-1

On page load, the react_ujs driver will scan the page and mount components using data-react-class and data-react-props.

The view helper's signature is: react_component(component_class_name, props={}, html_options={})

Abhi
  • 1
  • 3