module React
Public Class Methods
fix_props(props)
click to toggle source
# File lib/opal/react/component.rb, line 14 def self.fix_props(props) return `null` if props.nil? %x{ const jsProps = {}; #{ props.each { |key, value| if key.start_with?('on') chain = value value = -> (event) { chain.call(Native(event)) } elsif key == 'style' value = value.to_n end `jsProps[key] = value;` } } return jsProps; } end
fix_state(state)
click to toggle source
# File lib/opal/react/component.rb, line 33 def self.fix_state(state) return `null` if state.nil? %x{ const jsState = {}; #{ state.each { |key, value| `jsState[key] = value;` } } return jsState; } end