Module: React::Component::EventHandler

Defined in:
lib/react/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
# File 'lib/react/component/event_handler.rb', line 8

def event_handler(name, &block)
  event_handlers << name
  %x{
    self.react_component.prototype[name] = function(event, info) {
      #{ruby_event = ::React::SyntheticEvent.new(`event`)};
      #{`this.__ruby_instance`.instance_exec(ruby_event, `info`, &block)};
    }
  }
end

#event_handlersObject



4
5
6
# File 'lib/react/component/event_handler.rb', line 4

def event_handlers
  @event_handlers ||= []
end