0.2.1 • Published 1 year ago

react-native-use-list v0.2.1

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Alt text

Expo supported npm GitHub issues npm

Features

  • :open_book: Pagination
    • Navigate to next or previous page.
    • Go to a specific page (via index).
    • Page looping
    • Item alignment
  • :repeat: Pull to Refresh
    • isRefreshing state
  • :bulb: Open for more. Request a feature in the issues tab.

Supported components

  • FlatList
  • VirtualizedList
  • SectionList

Installation

Using npm:

npm install --save react-native-use-list

Using yarn:

yarn add react-native-use-list

Quickstart - Pagination

import { useList } from 'react-native-use-list';


const ref = useRef(null);

const { pageIndex, nextPage, prevPage, indexController } = useList({ ref });

return (
  <>
    <FlatList
      ...
      ref={ref} // <---
      {...indexController} // <---
    />
    <View style={styles.footer}>
      <Button text="<" onPress={prevPage} />
      <Text style={styles.footerIndex}>{pageIndex}</Text>
      <Button text=">" onPress={nextPage} />
    </View>
  </>
);

Quickstart - Pull to refresh

import { useList } from 'react-native-use-list';


const [data, setData] = useState([...]);

const updateData = async () => {
  ...
  setData([...])
}

const { isRefreshing, refreshController } = useList({
  onRefresh: updateData // <---
});

return (
  <>
    <Text>isRefreshing: {isRefreshing}</Text>
    <FlatList
      data={data}
      ...
      {...refreshController} // <---
    />
  </>
);

Folders

/example/examples
    /Flatlist
      Pagination.tsx
      AdvancedPagination.tsx
      PullToRefresh.tsx
    /VirtualizedList
      Pagination.tsx
      PullToRefresh.tsx
    /SectionList
      Pagination.tsx
      PullToRefresh.tsx

/example/templates (coming soon)

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

0.2.1

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago