2

I created a reactjs component by using react-rails gem:

@SettingWidget = React.createClass
  render: ->
    React.DOM.div
      React.DOM.span
        style:
          color: 'red'
        'Hello'
      React.DOM.span
        style:
        color: 'blue'
        'World'

In my view:

= react_component 'SettingWidget'

But I cannot render this component, I'm new in reactjs and rails, many thanks for help!

1 Answers1

0

If you don't specify any html option for element, put it {} like this:

@SettingWidget = React.createClass
  render: ->
    React.DOM.div {}, # Check here
      React.DOM.span
        style:
          color: 'red'
        'Hello'
      React.DOM.span
        style:
        color: 'blue'
        'World'
Hieu Pham
  • 6,577
  • 2
  • 30
  • 50