react-native#SectionListRenderItem TypeScript Examples

The following examples show how to use react-native#SectionListRenderItem. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HabitList.tsx    From nyxo-app with GNU General Public License v3.0 5 votes vote down vote up
HabitList: FC<Props> = ({ refreshControl, footer, header }) => {
  const dispatch = useAppDispatch()
  const navigation = useNavigation()
  const sections = useAppSelector(getHabitSections)

  const renderItem: SectionListRenderItem<Habit, unknown> = ({
    item,
    index
  }) => <HabitCard key={index} habit={item} />

  const goToHabits = () => {
    navigation.navigate('Habits')
  }

  const toggleModal = () => {
    dispatch(toggleNewHabitModal(true))
  }

  return (
    <List
      refreshControl={refreshControl}
      ListHeaderComponent={() => (
        <Fill>
          {header}
          <TitleRow>
            <TitleContainer>
              <H3>HABIT.HABIT_TITLE</H3>
            </TitleContainer>
            <NewHabitButton onPress={toggleModal}>
              <IconBold
                width={20}
                height={20}
                name="circleAdd"
                fill={colors.darkBlue}
              />
            </NewHabitButton>
          </TitleRow>
        </Fill>
      )}
      keyExtractor={(item) => item.title}
      sections={sections}
      renderItem={renderItem}
      ListFooterComponent={() => (
        <FooterRow>
          <TouchableOpacity onPress={goToHabits}>
            <ShowAllText>SEE_ALL</ShowAllText>
          </TouchableOpacity>
          {footer}
        </FooterRow>
      )}
    />
  )
}