Hook ScrollProvider to pager
This commit is contained in:
@@ -21,6 +21,7 @@ import {TabBar} from './TabBar'
|
|||||||
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries'
|
||||||
import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
|
import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback'
|
||||||
import {ListMethods} from '../util/List'
|
import {ListMethods} from '../util/List'
|
||||||
|
import {ScrollProvider} from '#/lib/ScrollContext'
|
||||||
|
|
||||||
export interface PagerWithHeaderChildParams {
|
export interface PagerWithHeaderChildParams {
|
||||||
headerHeight: number
|
headerHeight: number
|
||||||
@@ -299,23 +300,21 @@ function PagerItem({
|
|||||||
}
|
}
|
||||||
}, [scrollElRef, registerRef, index])
|
}, [scrollElRef, registerRef, index])
|
||||||
|
|
||||||
const scrollHandler = React.useMemo(
|
|
||||||
() => ({onScroll: onScrollWorklet}),
|
|
||||||
[onScrollWorklet],
|
|
||||||
)
|
|
||||||
|
|
||||||
if (!isReady || renderTab == null) {
|
if (!isReady || renderTab == null) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
return renderTab({
|
return (
|
||||||
headerHeight,
|
<ScrollProvider onScroll={onScrollWorklet}>
|
||||||
isFocused,
|
{renderTab({
|
||||||
onScroll: scrollHandler,
|
headerHeight,
|
||||||
scrollElRef: scrollElRef as React.MutableRefObject<
|
isFocused,
|
||||||
ListMethods | ScrollView | null
|
scrollElRef: scrollElRef as React.MutableRefObject<
|
||||||
>,
|
ListMethods | ScrollView | null
|
||||||
})
|
>,
|
||||||
|
})}
|
||||||
|
</ScrollProvider>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
const styles = StyleSheet.create({
|
||||||
|
|||||||
Reference in New Issue
Block a user