Last active
September 28, 2016 21:01
-
-
Save rodrigopr/c0111e9dacdb2351854ea8b420676cb8 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
// @flow | |
/* eslint-disable jsx-control-statements/jsx-jcs-no-undef, no-unused-vars */ | |
import React from 'react'; | |
import Relay from 'react-relay'; | |
/* | |
* Type mapping: | |
* D - DefaultProps | |
* P - Props | |
* S - State | |
* F - FragmentConfig | |
* V - VariablesConfig | |
*/ | |
type $Record<T> = {[key: $Keys<T>]: any}; | |
type StatelessComponent<P> = (props: P) => ?React$Element<any>; | |
type ContainerOptions<F, V> = { | |
fragments: F, | |
initialVariables?: V, | |
prepareVariables?: (prevArgs: $Record<V>) => $Record<V> | |
} | |
type PropsWithoutRelay<P> = $Diff<{ relay: RelayInstance<*> }, P>; | |
declare class RelayContainer<D, P, F, V> extends React$Component<D, P, void> { | |
static getFragment( | |
fragmentName: $Keys<F>, | |
variableMapping?: $Shape<V> | |
): any; | |
} | |
type createContainerDef = <D, P, S, F, V>( | |
BaseComponent: StatelessComponent<D> | Class<React$Component<D, P, S>>, | |
options: ContainerOptions<F, V> | |
) => Class<RelayContainer<D, PropsWithoutRelay<P>, F, V>>; | |
export type RelayInstance<V> = { | |
setVariable(params: $Shape<V>): void | |
} | |
export const createRelayContainer: createContainerDef = Relay.createContainer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment