Created
April 11, 2016 16:13
-
-
Save asolove/3aaf9398229d87294d8991f339936815 to your computer and use it in GitHub Desktop.
Flow type for react component with ref callback
This file contains hidden or 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
// I want to do something like this: | |
export default class Foo extends React.Component { | |
render() { | |
return <div ref={div => this._div = div}>I want a reference to this!</div> | |
} | |
} | |
// Flow says: "Property _div not found on Foo" | |
// Is there a way to give Foo the type Component & {_div?: Component} ? |
Just in case someone stumbles upon this page like I did:
https://flow.org/en/docs/frameworks/react/#toc-adding-types-for-react-refs
EDIT: found a better way
The link is broken. Here's the latest link https://flow.org/en/docs/react/refs/
@janzenz thank you!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@asolove did you figure this out?