Skip to content

Commit aa86c65

Browse files
Shaleen-25Shaleen Kachhara
andauthored
fix(useLayoutEffect) : useIsomorphicLayoutEffect to declutter Server Logs (#167)
* fix(useLayoutEffect): introduce useIsomorphicLayoutEffect to declutter server logs * refactor(lint): revert unintended linting changes * refactor(rc-util): utilize useLayoutEffect that already exits in rc-util Co-authored-by: Shaleen Kachhara <[email protected]>
1 parent 526bc63 commit aa86c65

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

examples/animate.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import * as React from 'react';
55
import CSSMotion from 'rc-animate/lib/CSSMotion';
66
import classNames from 'classnames';
77
import List, { ListRef } from '../src/List';
8+
import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect';
89
import './animate.less';
910

1011
let uuid = 0;
@@ -58,7 +59,7 @@ const MyItem: React.ForwardRefRenderFunction<any, MyItemProps> = (
5859
ref,
5960
) => {
6061
const motionRef = React.useRef(false);
61-
React.useLayoutEffect(() => {
62+
useLayoutEffect(() => {
6263
return () => {
6364
if (motionRef.current) {
6465
onAppear();

src/List.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { useRef, useState, useLayoutEffect } from 'react';
2+
import { useRef, useState } from 'react';
33
import classNames from 'classnames';
44
import Filler from './Filler';
55
import ScrollBar from './ScrollBar';
@@ -11,6 +11,7 @@ import useDiffItem from './hooks/useDiffItem';
1111
import useFrameWheel from './hooks/useFrameWheel';
1212
import useMobileTouchMove from './hooks/useMobileTouchMove';
1313
import useOriginScroll from './hooks/useOriginScroll';
14+
import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect';
1415

1516
const EMPTY_DATA = [];
1617

src/hooks/useMobileTouchMove.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as React from 'react';
22
import { useRef } from 'react';
3+
import useLayoutEffect from 'rc-util/lib/hooks/useLayoutEffect';
34

45
const SMOOTH_PTG = 14 / 15;
56

@@ -67,7 +68,7 @@ export default function useMobileTouchMove(
6768
}
6869
};
6970

70-
React.useLayoutEffect(() => {
71+
useLayoutEffect(() => {
7172
if (inVirtual) {
7273
listRef.current.addEventListener('touchstart', onTouchStart);
7374
}

0 commit comments

Comments
 (0)