Skip to content

Commit 9069169

Browse files
fix(@clayui/slider): avoid async rendering to render synchronous changes before repaint
1 parent eb2ad89 commit 9069169

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/clay-slider/src/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66

77
import classNames from 'classnames';
8-
import React, {useEffect, useRef, useState} from 'react';
8+
import React, {useLayoutEffect, useRef, useState} from 'react';
99

1010
interface IProps extends React.InputHTMLAttributes<HTMLInputElement> {
1111
/**
@@ -92,7 +92,7 @@ const ClaySlider: React.FunctionComponent<IProps> = ({
9292
const sliderRef = useRef<HTMLInputElement | null>(null);
9393
const thumbRef = useRef<HTMLDivElement | null>(null);
9494

95-
useEffect(() => {
95+
useLayoutEffect(() => {
9696
if (sliderRef.current && thumbRef.current) {
9797
const thumbWidth = thumbRef.current.clientWidth;
9898

0 commit comments

Comments
 (0)