Created
October 14, 2016 20:43
-
-
Save limscoder/a45eca06f3c6c77fbfc1c614830b223d to your computer and use it in GitHub Desktop.
Playing with ways to express immutable react elements with flowtype
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
type FunctionComponent<P, S> = (props: P, context: S) => ?React$Element<any>; | |
type ClassComponent<D, P, S> = Class<React$Component<D, P, S>>; | |
type ReactComponent<D, P, S> = FunctionComponent<P, S> | ClassComponent<D, P, S>; | |
function ImmutableComponent<D, P, S, T: ReactComponent<D, P, S>>({ component: Component, componentProps }: { | |
component: T, | |
componentProps: P | |
}) { | |
return <Component { ...componentProps }/>; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment