Closed sravanshty closed 6 years ago
Hello.
To access internal method in object from out side, you can make external reference something like this:
let handleStartRef;
class SomeComponent extends Component {
constructor() {
handleStartRef = this.handleStart;
}
handleStart = () => {
// ...
}
...
}
// Outside of SomeComponent
// Make sure that at least one object instantiated SomeComponent constructor(class)
document.getElementById("some-button").onclick = function() {
if(typeof handleStartRef === "undefined") return;
handleStartRef(); // Invoke SomeComponent::handleStart
}
I won't sure the code works because it's just pseudo code, however this kind of approach will works because I already used some react apps.
I'm closing this, if you have any issue, you can freely re-open this.
Hello,
As per the code we can access onStart={this.handleStart}......render = ({ start...}). But i just wanted to invoke handleStart function outside of. Like in some button click i just wanted to invoke. Could you please help me out this solution.
Thanks, Sravan Kumar Shetty