Re:A Primer for Building Single Page Applications with React
by JustSomeNobody on Tuesday March 24, 2015 @11:42AM
(#9257284)
Not familiar with react and barely JavaScript, but why is <a onClick="function('value')"> bad? I mean as longs as the function calls a function on another module and doesn't contain any more logic than that. The other module remains testable, and the only logic in the UI is a function call.
If the interface of the module changes, sure the UI would have to change, but I tend to think people over think things at this point (my opinion and I hope it doesn't distract from my original question).
[ Parent
| on HN ]
Re:A Primer for Building Single Page Applications with React
by mtrimpe on Tuesday March 24, 2015 @03:01PM
(#9258658)
As far as I'm concerned <a onClick="function('value')"> was bad because 'function' was a global variable reference.
I don't think that's the case for React though so I'm not sure if the GP saw some other drawbacks in it (apart from the aesthetic of separating logic from presentation.)
Re:A Primer for Building Single Page Applications with React
by Bahamut on Tuesday March 24, 2015 @04:48PM
(#9259381)
In React, you would do <a onClick={this.props.foo('value')}> (for example) - JSX would interpolate that and set up the appropriate click binding, and the function is local to the component.