Skip to content

Commit

Permalink
Merge pull request #29745 from software-mansion-labs/ts-migration/sec…
Browse files Browse the repository at this point in the history
…tion-list-component

[TS migration] Migrate 'SectionList' component to TypeScript
  • Loading branch information
johnmlee101 authored Nov 10, 2023
2 parents 63875ad + 533bbd2 commit a941a6a
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import React, {forwardRef} from 'react';
import {SectionList} from 'react-native';
import {SectionList as RNSectionList} from 'react-native';
import ForwardedSectionList from './types';

const SectionListWithRef = forwardRef((props, ref) => (
<SectionList
// eslint-disable-next-line react/function-component-definition
const SectionListWithRef: ForwardedSectionList = (props, ref) => (
<RNSectionList
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
ref={ref}
Expand All @@ -11,8 +13,8 @@ const SectionListWithRef = forwardRef((props, ref) => (
// eslint-disable-next-line react/jsx-props-no-multi-spaces
removeClippedSubviews
/>
));
);

SectionListWithRef.displayName = 'SectionListWithRef';

export default SectionListWithRef;
export default forwardRef(SectionListWithRef);
3 changes: 0 additions & 3 deletions src/components/SectionList/index.js

This file was deleted.

16 changes: 16 additions & 0 deletions src/components/SectionList/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React, {forwardRef} from 'react';
import {SectionList as RNSectionList} from 'react-native';
import ForwardedSectionList from './types';

// eslint-disable-next-line react/function-component-definition
const SectionList: ForwardedSectionList = (props, ref) => (
<RNSectionList
// eslint-disable-next-line react/jsx-props-no-spreading
{...props}
ref={ref}
/>
);

SectionList.displayName = 'SectionList';

export default forwardRef(SectionList);
9 changes: 9 additions & 0 deletions src/components/SectionList/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {ForwardedRef} from 'react';
import {SectionList, SectionListProps} from 'react-native';

type ForwardedSectionList = {
(props: SectionListProps<SectionList>, ref: ForwardedRef<SectionList>): React.ReactNode;
displayName: string;
};

export default ForwardedSectionList;

0 comments on commit a941a6a

Please sign in to comment.