55 CellSize ,
66 GutterSize ,
77 HorizontalAlignment ,
8- IStyledCellProps ,
98 StyledCell ,
109 StyledGridLayout ,
1110 VerticalAlignment
@@ -53,11 +52,6 @@ interface IVerticalAlignmentDefinition {
5352}
5453
5554interface IGridLayoutCell {
56- /**
57- * Key for the cell. This is important for animations, as cells with the same key will be kept unanimated
58- * when transitioning. Defaults to the index of the cell.
59- */
60- key ?: string | number
6155 /** The content to place within the cell */
6256 content ?: JSX . Element | string | null
6357 /** The size this cell takes up within the grid */
@@ -103,10 +97,11 @@ type GridChild =
10397 | false
10498 | null
10599 | undefined
100+ | GridChild [ ]
106101
107102interface IGridLayoutPropsWithChildren extends IGridLayoutBaseProps {
108103 /** The cell components to place within the grid */
109- children : GridChild [ ] | GridChild
104+ children : GridChild
110105}
111106
112107type GridLayoutProps = IGridLayoutPropsWithCells | IGridLayoutPropsWithChildren
@@ -144,16 +139,18 @@ export class GridLayout extends React.PureComponent<GridLayoutProps, never> {
144139 if ( 'cells' in this . props ) {
145140 renderChildren = this . props . cells && this . props . cells . map ( this . getCellForDefinition )
146141 } else if ( this . props . children ) {
147- renderChildren = React . Children . map <
148- React . ReactElement | false | null | undefined ,
149- GridChild
150- > ( this . props . children , ( child ) => {
142+ renderChildren = React . Children . map ( this . props . children , ( child ) => {
151143 if ( ! child ) {
152144 return child
153145 }
154146
147+ // This can never happen, as React.children expands out child arrays automatically
148+ // Kept because otherwise typescript complains (typing of .map isn't great)
149+ if ( Array . isArray ( child ) ) {
150+ return null
151+ }
152+
155153 const {
156- key,
157154 size,
158155 offset,
159156 flexHorizontalAlignment,
@@ -162,7 +159,6 @@ export class GridLayout extends React.PureComponent<GridLayoutProps, never> {
162159
163160 return (
164161 React . cloneElement ( child , {
165- key,
166162 size,
167163 offset,
168164 displayType,
@@ -205,7 +201,6 @@ export class GridLayout extends React.PureComponent<GridLayoutProps, never> {
205201 } = this . props
206202
207203 const {
208- key,
209204 content,
210205 size,
211206 displayType,
@@ -216,7 +211,7 @@ export class GridLayout extends React.PureComponent<GridLayoutProps, never> {
216211
217212 return (
218213 < StyledCell
219- key = { key || index }
214+ key = { index }
220215 size = { size || 'auto' }
221216 offset = { offset || 0 }
222217 gridColumns = { gridColumns ! }
0 commit comments