[Relay] Add generics for getConnectionFromProps.

This commit is contained in:
Eloy Durán
2017-10-11 16:23:14 +02:00
parent 3439a2d7a1
commit 091c46291e
2 changed files with 4 additions and 4 deletions

View File

@@ -105,9 +105,9 @@ export function FragmentVariablesGetter(
prevVars: RelayCommonTypes.Variables,
totalCount: number
): RelayCommonTypes.Variables;
export interface ConnectionConfig {
export interface ConnectionConfig<T> {
direction?: "backward" | "forward";
getConnectionFromProps?(props: object): ConnectionData | undefined | null;
getConnectionFromProps?(props: T): ConnectionData | undefined | null;
getFragmentVariables?: typeof FragmentVariablesGetter;
getVariables(
props: { [propName: string]: any },
@@ -119,7 +119,7 @@ export interface ConnectionConfig {
export function createPaginationContainer<T>(
Component: ReactBaseComponent<T>,
fragmentSpec: GraphQLTaggedNode | GeneratedNodeMap,
connectionConfig: ConnectionConfig
connectionConfig: ConnectionConfig<T>
): ReactBaseComponent<T>;
// ~~~~~~~~~~~~~~~~~~~~~

View File

@@ -182,7 +182,7 @@ const FeedPaginationContainer = createPaginationContainer(
},
{
direction: "forward",
getConnectionFromProps(props: { user: { feed: any } }) {
getConnectionFromProps(props) {
return props.user && props.user.feed;
},
getFragmentVariables(prevVars, totalCount) {