Last active
March 28, 2019 16:05
-
-
Save avianto/3a230fa2c485a373d4034d5b6ab6048c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Access method inside React component: | |
OLD (reliable but not future proof) | |
const ourComponent = ReactDOM.render(<OurComponent />, document.getElementById("app")); | |
ourComponent.someMethod() // would call the method | |
NEW | |
ReactDOM.render(<Page ref={(ourComponent) => {window.ourComponent = ourComponent}} />, document.getElementById("app")); | |
window.ourComponent.someMethod() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment