Skip to content

Commit 1e14c62

Browse files
committed
fix(range): taro环境异步渲染useReady不会触发
1 parent f819320 commit 1e14c62

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/packages/range/range.taro.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ import React, {
22
FunctionComponent,
33
useCallback,
44
useEffect,
5+
useLayoutEffect,
56
useMemo,
67
useRef,
78
useState,
89
} from 'react'
910
import classNames from 'classnames'
1011
import { Text, View } from '@tarojs/components'
11-
import { useReady, nextTick } from '@tarojs/taro'
12+
import { nextTick } from '@tarojs/taro'
1213
import { pxTransform } from '@/utils/taro/px-transform'
1314
import { useTouch } from '@/hooks/use-touch'
1415
import { ComponentDefaults } from '@/utils/typings'
@@ -286,7 +287,7 @@ export const Range: FunctionComponent<
286287
[innerValue, disabled, isRange, min, scope, updateValue, vertical]
287288
)
288289

289-
useReady(() => {
290+
useLayoutEffect(() => {
290291
const getRootRect = async () => {
291292
if (root.current) {
292293
const rect = await getRectInMultiPlatform(root.current)
@@ -296,7 +297,7 @@ export const Range: FunctionComponent<
296297
nextTick(() => {
297298
getRootRect()
298299
})
299-
})
300+
}, [])
300301

301302
const onTouchStart = useCallback(
302303
(event: any) => {

0 commit comments

Comments
 (0)