Rename inner/outer TagName to ElementType

This commit also widens the type to be closer to what React.createElement accepts, since ultimately these props are passed straight through to it.
This commit is contained in:
Alex Guerra
2019-02-07 12:37:19 -06:00
parent 495d2da628
commit 5fdb0ee156
2 changed files with 31 additions and 7 deletions
+25 -1
View File
@@ -4,7 +4,15 @@
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import { Component, ComponentType, CSSProperties, Ref, Key } from "react";
import {
Component,
ComponentType,
CSSProperties,
Ref,
Key,
FunctionComponent,
ComponentClass
} from "react";
export type Direction = "vertical" | "horizontal";
export type ScrollDirection = "forward" | "backward";
@@ -25,17 +33,27 @@ export interface GridChildComponentProps {
isScrolling?: boolean;
}
// This is supposed to represent the type of the first parameter to
// React.createElement.
type ReactElementType = FunctionComponent<any> | ComponentClass<any> | string;
export interface CommonProps {
/**
* Optional CSS class to attach to outermost <div> element.
*/
className?: string;
/**
* Tag name passed to document.createElement to create the inner container element. This is an advanced property; in most cases, the default ("div") should be used.
*/
innerElementType?: ReactElementType;
/**
* Ref to attach to the inner container element. This is an advanced property.
*/
innerRef?: Ref<any>;
/**
* Tag name passed to document.createElement to create the inner container element. This is an advanced property; in most cases, the default ("div") should be used.
*
* @deprecated since 1.4.0
*/
innerTagName?: string;
/**
@@ -44,12 +62,18 @@ export interface CommonProps {
* Item data is useful for item renderers that are class components.
*/
itemData?: any;
/**
* Tag name passed to document.createElement to create the outer container element. This is an advanced property; in most cases, the default ("div") should be used.
*/
outerElementType?: ReactElementType;
/**
* Ref to attach to the outer container element. This is an advanced property.
*/
outerRef?: Ref<any>;
/**
* Tag name passed to document.createElement to create the outer container element. This is an advanced property; in most cases, the default ("div") should be used.
*
* @deprecated since 1.4.0
*/
outerTagName?: string;
/**
+6 -6
View File
@@ -66,7 +66,7 @@ const FixedSizeListTestOptionalProps: React.SFC<{ testBool: boolean }> = ({
direction={testBool ? "vertical" : "horizontal"}
initialScrollOffset={0}
innerRef={anyRef}
innerTagName="div"
innerElementType="div"
itemData={{ foo: "bar" }}
itemKey={index => "foo" + index.toString()}
onItemsRendered={({
@@ -81,7 +81,7 @@ const FixedSizeListTestOptionalProps: React.SFC<{ testBool: boolean }> = ({
visibleStopIndex
}
useIsScrolling={true}
outerTagName="div"
outerElementType="div"
style={{ color: "cyan" }}
overscanCount={0}
outerRef={anyRef}
@@ -112,7 +112,7 @@ const VariableSizeListTestOptionalProps: React.SFC<{ testBool: boolean }> = ({
direction={testBool ? "vertical" : "horizontal"}
initialScrollOffset={0}
innerRef={anyRef}
innerTagName="div"
innerElementType="div"
itemData={{ foo: "bar" }}
itemKey={index => "foo" + index.toString()}
onItemsRendered={({
@@ -127,7 +127,7 @@ const VariableSizeListTestOptionalProps: React.SFC<{ testBool: boolean }> = ({
visibleStopIndex
}
useIsScrolling={true}
outerTagName="div"
outerElementType="div"
style={{ color: "cyan" }}
overscanCount={0}
outerRef={anyRef}
@@ -161,7 +161,7 @@ const VariableSizeGridTestOptionalProps: React.SFC = () => (
initialScrollLeft={0}
initialScrollTop={0}
innerRef={anyRef}
innerTagName="div"
innerElementType="div"
itemData={{ foo: "bar" }}
itemKey={({ columnIndex, rowIndex }) =>
columnIndex.toString() + rowIndex.toString()
@@ -184,7 +184,7 @@ const VariableSizeGridTestOptionalProps: React.SFC = () => (
verticalScrollDirection
}) => undefined}
outerRef={anyRef}
outerTagName="div"
outerElementType="div"
overscanColumnsCount={5}
overscanRowsCount={5}
ref="ref"