Skip to content

Instantly share code, notes, and snippets.

@asolove
Created April 11, 2016 16:13
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asolove/3aaf9398229d87294d8991f339936815 to your computer and use it in GitHub Desktop.
Save asolove/3aaf9398229d87294d8991f339936815 to your computer and use it in GitHub Desktop.
Flow type for react component with ref callback
// 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} ?
@nikgraf
Copy link

nikgraf commented Aug 29, 2016

@asolove did you figure this out?

@chilldriven
Copy link

chilldriven commented Oct 31, 2016

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

@janzenz
Copy link

janzenz commented Sep 10, 2017

The link is broken. Here's the latest link https://flow.org/en/docs/react/refs/

@riseremi
Copy link

@janzenz thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment