refactor(mobile): clean set page logic

This commit is contained in:
Stephen Zhou 2025-06-30 15:18:59 +08:00
parent ae005c1708
commit 41482bccb3
No known key found for this signature in database
1 changed files with 1 additions and 9 deletions

View File

@ -1,7 +1,7 @@
import { cn } from "@follow/utils"
import { cssInterop } from "nativewind"
import type { FC, ReactNode, Ref } from "react"
import { useEffect, useImperativeHandle, useRef, useState } from "react"
import { useImperativeHandle, useRef, useState } from "react"
import type { StyleProp, ViewStyle } from "react-native"
import { StyleSheet } from "react-native"
@ -50,14 +50,6 @@ export const PagerView: FC<PagerViewProps> = ({
const [currentPage, setCurrentPage] = useState(page ?? 0)
const nativeRef = useRef<PagerRef>(null)
useEffect(() => {
if (nativeRef.current) {
const state = nativeRef.current.getState()
if (state === "idle" && currentPage !== nativeRef.current.getPage()) {
nativeRef.current.setPage(currentPage)
}
}
}, [currentPage])
useImperativeHandle(ref, () => ({
setPage: (index: number) => {
setCurrentPage(index)