@stream-io/flat-list-mvcp
TypeScript icon, indicating that this package has built-in type declarations

0.10.3 • Public • Published

maintainVisibleContentPosition prop support for Android react-native.

License Npm Package Compatibility

[ Built with at Stream ]

In react-native, ScrollView (and FlatList) component have support for a prop maintainVisibleContentPosition, which is really useful for chat-like applications where you want to see new messages scroll into place. Also you might need it in other applications where you need bi-directional infinite scroll. Although currently its only supported on iOS. So here we have built a simple wrapper for FlatList and ScrollView to add support for this prop for android. On iOS, we simply return FlatList and ScrollView from react-native package.

We built this wrapper for our in-house react-native chat sdk, but we are making it public, in case it helps other devs from react-native community.

Before you proceed, please don't forget to also check other relevant packages, built at Stream:

⚠️ Horizontal list is currently not supported on this package.

Example

#  clone the repo
git clone https://github.com/GetStream/flat-list-mvcp.git
cd flat-list-mvcp/Example

# Install npm and pod dependencies
yarn; npx pod-install;

# run the app
npx react-native run-android

Installation

yarn add @stream-io/flat-list-mvcp

Usage

import { FlatList, ScrollView } from '@stream-io/flat-list-mvcp';

<FlatList
    maintainVisibleContentPosition={{
        autoscrollToTopThreshold: 10,
        minIndexForVisible: 1,
    }}
    ...
/>

<ScrollView
    maintainVisibleContentPosition={{
        autoscrollToTopThreshold: 10,
        minIndexForVisible: 1,
    }}
    ...
/>

Expo support

This package doesn't support Expo managed workflow. There is a feature request open for expo - https://expo.canny.io/feature-requests/p/android-maintainvisiblecontentposition-on-flatlist (please upvote)

Credits

Thanks to stackia for https://github.com/facebook/react-native/pull/29466#issuecomment-664367382

Contributing

PRs for improvement are welcome :)

License

MIT

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.10.317,554latest
0.11.0-dev.01dev
0.10.2-rc.21beta

Version History

VersionDownloads (Last 7 Days)Published
0.10.317,554
0.10.21,144
0.10.2-rc.21
0.10.2-rc.11
0.11.0-dev.01
0.10.11,565
0.10.1-beta.11
0.10.1-beta.01
0.10.05
0.10.0-beta.11
0.10.0-beta.01
0.0.912
0.0.9-dev.11
0.0.9-dev.02
0.0.81
0.0.8-dev.01
0.0.61
0.0.6-dev.41
0.0.6-dev.31
0.0.6-dev.21
0.0.6-dev.112
0.0.6-dev.012
0.0.51
0.0.41
0.0.31
0.0.3-dev.01
0.0.21
0.0.11

Package Sidebar

Install

npm i @stream-io/flat-list-mvcp

Weekly Downloads

20,326

Version

0.10.3

License

MIT

Unpacked Size

175 kB

Total Files

51

Last publish

Collaborators

  • vangalilea88
  • martincupela
  • stream-release-bot
  • caleb.murphy
  • zita.szupera
  • tbarbugli
  • tschellenbach
  • vishtree