is it possible to call a specific method of a component? window.Component.method
doesn't work...
Any help is appreciated, thanks in advance.
Asked
Active
Viewed 564 times
0

Tom
- 520
- 2
- 17
1 Answers
0
var testClass = React.createClass({
handleClick: function(){
alert('you clicked me');
},
render: function(){
<button onClick={this.handleClick}></button>
}
});
Dont know if this is a rail-specific thing, but if its just react components you mean, this should do the trick

thsorens
- 1,308
- 12
- 21
-
Hi thanks for your answer. What i actually mean is to call the react method from a javascript file - located lets say in the views... – Tom Feb 04 '15 at 06:54
-
Well, why would you wanna do that? That kinda breaks the point of doing react in the first place? – thsorens Feb 04 '15 at 07:52
-
Right, yes. Just out of curiosity. I always thought that the react methods are part of the window object - seems this is not the case... – Tom Feb 04 '15 at 08:03
-
1React consists of a virtual dom. Manipulating the dom will get things out of sync. – thsorens Feb 04 '15 at 08:06