Skip to content

Commit

Permalink
WIP: CellRendererComponent prop
Browse files Browse the repository at this point in the history
  • Loading branch information
Marek Fořt committed Apr 29, 2022
1 parent 26a7931 commit 4aabec1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/FlashList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
import StickyContainer, { StickyContainerProps } from "recyclerlistview/sticky";

import AutoLayoutView, { BlankAreaEventHandler } from "./AutoLayoutView";
import ItemContainer from "./CellContainer";
import CellContainer from "./CellContainer";
import { PureComponentWrapper } from "./PureComponentWrapper";
import GridLayoutProviderWithProps from "./GridLayoutProviderWithProps";
import CustomError from "./errors/CustomError";
Expand Down Expand Up @@ -132,6 +132,8 @@ export interface FlashListProps<T> extends FlatListProps<T> {
| ((info: { viewableItems: ViewToken[]; changed: ViewToken[] }) => void)
| null
| undefined;

CellRendererComponent?: typeof CellContainer | undefined;
}

export interface FlashListState<T> {
Expand Down Expand Up @@ -536,8 +538,10 @@ class FlashList<T> extends React.PureComponent<
};

private itemContainer = (props: any, parentProps: any) => {
const CellRendererComponent =
this.props.CellRendererComponent ?? CellContainer;
return (
<ItemContainer
<CellRendererComponent
{...props}
style={{
...props.style,
Expand All @@ -554,7 +558,7 @@ class FlashList<T> extends React.PureComponent<
arg={parentProps.index}
renderer={this.getCellContainerChild}
/>
</ItemContainer>
</CellRendererComponent>
);
};

Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ export {
export { JSFPSMonitor, JSFPSResult } from "./benchmark/JSFPSMonitor";
export { autoScroll, Cancellable } from "./benchmark/AutoScrollHelper";
export { default as ViewToken } from "./ViewToken";
export { default as CellContainer } from "./CellContainer";

0 comments on commit 4aabec1

Please sign in to comment.