Skip to content

Commit

Permalink
Add generic types to improve type safety
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabriel de Oliveira Rohden committed Aug 18, 2019
1 parent 6333189 commit c8ead96
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/Modalize.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ const AnimatedFlatList = Animated.createAnimatedComponent(FlatList);
const AnimatedSectionList = Animated.createAnimatedComponent(SectionList);
const THRESHOLD = 150;

export default class Modalize extends React.Component<IProps, IState> {
export default class Modalize<FlatListItem = any, SectionListItem = any>
extends React.Component<IProps<FlatListItem, SectionListItem>, IState> {

static defaultProps = {
handlePosition: 'outside',
Expand Down Expand Up @@ -47,7 +48,7 @@ export default class Modalize extends React.Component<IProps, IState> {
private modalOverlayTap: React.RefObject<TapGestureHandler> = React.createRef();
private willCloseModalize: boolean = false;

constructor(props: IProps) {
constructor(props: IProps<FlatListItem, SectionListItem>) {
super(props);

const fullHeight = isIos() ? screenHeight : screenHeight - 10;
Expand Down
6 changes: 3 additions & 3 deletions src/Options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export interface IConfigProps {
spring: ISpringProps;
}

export interface IProps {
export interface IProps<FlatListItem = any, SectionListItem = any> {
/**
* A React component that will define the content of the modal.
*/
Expand Down Expand Up @@ -117,12 +117,12 @@ export interface IProps {
/*
* An object to pass any of the react-native FlatList's props.
*/
flatListProps?: FlatListProps<any>;
flatListProps?: FlatListProps<FlatListItem>;

/*
* An object to pass any of the react-native SectionList's props.
*/
sectionListProps?: SectionListProps<any>;
sectionListProps?: SectionListProps<SectionListItem>;

/**
* A header component outside of the ScrollView, on top of the modal.
Expand Down

0 comments on commit c8ead96

Please sign in to comment.