Internal call of event handler for React.DOM component

105 views
Skip to first unread message

Lukáš Horák

unread,
Feb 3, 2014, 7:17:31 AM2/3/14
to est...@googlegroups.com
I started use only 'este.react' from este.js framework, because there is well resolved compiling app with Closure Compiler's advanced optimizations. It works like a charm, except one weird behaviour. When I have component with defined handler method for event (eg. onClick) and I want to call manually from any other component's method, it doesn't work (method is never called). Example:

MyComponent = este.react.create (`/** @lends {React.ReactComponent.prototype} */`)
  ###*
  * @param {Event=} ev
  ###
  handleClick: (ev) ->
    # handling of click event

  ###*
  * @param {Event} ev
  ###
  handleDifferentClick: (ev) ->
    # do something different

    @handleClick()      # This call doesn't work... 

  render: ->
    @div { 'className': 'parentDiv' }, [
      @button { 'name': 'btn1', 'onClick': @handleClick}, 'Button 1'
      @button { 'name': 'btn2', 'onClick': @handleDifferentClick}, 'Button 2'
    ]

Calling `handleClick` inside `handleDifferentWork` doesn't work, but when I would remove Button 1 so `handleClick` won't be handler function, it works. Resolution of this problem is enclose function name with quotes at definition and with brackets when calling it. But it doesn't look well and adds it bytes to destination file since full method name is used. Is there something what I could do better?

Daniel Steigerwald

unread,
Feb 3, 2014, 5:50:28 PM2/3/14
to est...@googlegroups.com
Interesting. No time to check it right now, but you can debug it and send PR. Otherwise I will check at end of this week.


--
You received this message because you are subscribed to the Google Groups "Este.js - The state of art Javascript framework and dev stack" group.
To unsubscribe from this group and stop receiving emails from it, send an email to estejs+un...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Lukáš Horák

unread,
Feb 5, 2014, 3:53:50 AM2/5/14
to est...@googlegroups.com
After update este-library on version 5.2.21 and closure-library on release 74667f60a4, it's ok. So you don't need to deal with it.

Daniel Steigerwald

unread,
Feb 5, 2014, 4:01:52 AM2/5/14
to est...@googlegroups.com
Yes, because event handlers names were not part of React externs. I fixed it. Thank you for reporting,


On Wed, Feb 5, 2014 at 12:53 AM, Lukáš Horák <horak...@gmail.com> wrote:
After update este-library on version 5.2.21 and closure-library on release 74667f60a4, it's ok. So you don't need to deal with it.

--

Lukáš Horák

unread,
Feb 5, 2014, 4:05:18 AM2/5/14
to est...@googlegroups.com
Thank you for so fast fix ;)
Reply all
Reply to author
Forward
0 new messages