mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-12 19:59:02 +08:00
[Relay] Add generics for getConnectionFromProps.
This commit is contained in:
6
types/react-relay/modern.d.ts
vendored
6
types/react-relay/modern.d.ts
vendored
@@ -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>;
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user