@resourge/react-fetch
Version:
[](LICENSE)
36 lines (33 loc) • 922 B
JavaScript
/**
* react-fetch v1.43.1
*
* Copyright (c) resourge.
*
* This source code is licensed under the MIT license found in the
* LICENSE.md file in the root directory of this source tree.
*
* @license MIT
*/
import { useRef, useEffect } from 'react';
import { IS_DEV } from '../../utils/constants';
import { useEffectEvent } from '../useEffectEvent';
const useOnScroll = scrollMethod => {
const ref = useRef(null);
const onScrollRef = useEffectEvent(scrollMethod);
if (IS_DEV) {
useEffect(() => {
if (!ref.current) {
throw new Error('On react-native \'ref\' needs to be set, as react-native doesn\'t have window');
}
}, []);
}
const onScroll = event => {
onScrollRef({
left: event.nativeEvent.contentOffset.x,
top: event.nativeEvent.contentOffset.y
});
};
return [ref, onScroll];
};
export { useOnScroll };
//# sourceMappingURL=useOnScroll.native.js.map