Module: React::FunctionComponent::EventHandler
- Defined in:
- lib/react/function_component/event_handler.rb
Instance Method Summary collapse
Instance Method Details
#event_handler(name, &block) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/react/function_component/event_handler.rb', line 8 def event_handler(name, &block) event_handlers << name %x{ var fun = function(event, info) { if (typeof event === "object") { #{ruby_event = ::React::SyntheticEvent.new(`event`)}; } else { #{ruby_event = `event`}; } #{`this`.instance_exec(ruby_event, `info`, &block)}; } self[name] = fun; } end |
#event_handlers ⇒ Object
4 5 6 |
# File 'lib/react/function_component/event_handler.rb', line 4 def event_handlers @event_handlers ||= [] end |