Skip to content

Instantly share code, notes, and snippets.

@gaearon
Created March 27, 2018 23:29
Show Gist options
  • Star 33 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save gaearon/88634d27abbc4feeb40a698f760f3264 to your computer and use it in GitHub Desktop.
Save gaearon/88634d27abbc4feeb40a698f760f3264 to your computer and use it in GitHub Desktop.
class Example extends React.Component<
Props,
State,
Snapshot
> {
static getDerivedStateFromProps(
nextProps: Props,
prevState: State
): $Shape<State> | null {
// ...
}
getSnapshotBeforeUpdate(
prevProps: Props,
prevState: State
): Snapshot {
// ...
}
}
@geekf
Copy link

geekf commented Mar 28, 2018

Stupid question, but is this TypeScript? The file extensions says .js.

@theneva
Copy link

theneva commented Mar 28, 2018

@geekf it's Flow

@simonbuchan
Copy link

Replace $Shape with Partial and you have typescript, though.

@devCola
Copy link

devCola commented Jul 10, 2018

@simonbuchan just wondering... will Flow and Typescript merge?

@oshalygin
Copy link

This is Flow

@eugeneblog
Copy link

How to define Snapshot?

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