Skip to content
This repository has been archived by the owner on Sep 17, 2023. It is now read-only.

axinvd/react-native-scrollview-maintain

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

react-native-scrollview-maintain

install yarn add react-native-scrollview-maintain

usage

call enableMaintain before use scroll component

//index.js

import { AppRegistry } from 'react-native';
import { App } from './src/App';
import { name as appName } from './app.json';
import {enableMaintain} from 'react-native-scrollview-maintain';

enableMaintain();

AppRegistry.registerComponent(appName, () => App);

or

import {enableMaintainVisibleContentPosition, disableMaintainVisibleContentPosition} from 'react-native-scrollview-maintain';

...

// `ref` is the ref to your ScrollView / FlatList
useEffect(() => {
    let cleanupPromise: Promise<number> | undefined;
    if (Constants.isAndroid) {
        const viewTag = findNodeHandle(ref.current);
        cleanupPromise = enableMaintainVisibleContentPosition(viewTag, 0);
    }
    return () => {
        void cleanupPromise?.then((handle) => {
        void disableMaintainVisibleContentPosition(handle);
    };
}, [ref]);

License

React native screens library is licensed under The MIT License.

Credits

Module for those who need maintainVisibleContentPosition on Android now but don't want to maintain your own RN fork RNPullRequest

Thans for workaround Stackie Jia and Maxime Bertheau

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published