Module: React
- Defined in:
- lib/opal/react/dsl.rb,
lib/opal/react/react.rb,
lib/opal/react/window.rb,
lib/opal/react/component.rb
Defined Under Namespace
Modules: DSL, Window
Classes: Component, ShallowWrapper
Class Method Summary
collapse
Class Method Details
.fix_props(props) ⇒ Object
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# 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) ⇒ Object
33
34
35
36
37
38
39
40
|
# 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
|