Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: ts typings for sectionlist to mirror rn core types #475

Merged
merged 1 commit into from
Jun 2, 2021
Merged

fix: ts typings for sectionlist to mirror rn core types #475

merged 1 commit into from
Jun 2, 2021

Conversation

vonovak
Copy link
Contributor

@vonovak vonovak commented Jun 2, 2021

Please provide enough information so that others can review your pull request:

Motivation

the types for SectionList in RN core are:

interface SectionListProps<ItemT, SectionT = DefaultSectionT>

but the typings of the exported BottomSheetSectionList are BottomSheetSectionListProps<T> and do not allow passing the second parameter. This PR aligns the typings to be the same as in RN core

can be tested with:

import { SectionList as RNSectionList, Text } from 'react-native';
import React from 'react';
import BottomSheetSectionList from './BottomSheetSectionList';

type ItemType = {
  number: number;
};
type SectionsType = {
  title: string;
  data: Array<ItemType>;
};
export const TSTest = () => {
  const sections = [
    {
      title: 'Main dishes',
      data: [{ number: 1 }, { number: 2 }],
    },
    {
      title: 'side dishes',
      data: [{ number: 1 }, { number: 2 }],
    },
  ];
  return (
    <>
      <RNSectionList<ItemType, SectionsType>
        sections={sections}
        renderItem={props => <Text>{props.item}</Text>}
      />
      <BottomSheetSectionList<ItemType, SectionsType>
        sections={sections}
        renderItem={props => <Text>{props.item}</Text>}
      />
    </>
  );
};

@gorhom
Copy link
Owner

gorhom commented Jun 2, 2021

thanks !

@gorhom gorhom merged commit dd9dbdc into gorhom:v4 Jun 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants