Skip to content

Commit

Permalink
fix: πŸ› error in React 17 (#67)
Browse files Browse the repository at this point in the history
1. replace useEffect with useLayoutEffect

βœ… Closes: ant-design/ant-design#27006
  • Loading branch information
jueinin committed Oct 9, 2020
1 parent 1ee9665 commit 37f3aa2
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/animate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const MyItem: React.ForwardRefRenderFunction<any, MyItemProps> = (
ref,
) => {
const motionRef = React.useRef(false);
React.useEffect(() => {
React.useLayoutEffect(() => {
return () => {
if (motionRef.current) {
onAppear();
Expand Down
2 changes: 1 addition & 1 deletion src/List.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ export function RawList<T>(props: ListProps<T>, ref: React.Ref<ListRef>) {
return true;
});

React.useEffect(() => {
React.useLayoutEffect(() => {
// Firefox only
function onMozMousePixelScroll(e: Event) {
if (inVirtual) {
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useMobileTouchMove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export default function useMobileTouchMove(
}
};

React.useEffect(() => {
React.useLayoutEffect(() => {
if (inVirtual) {
listRef.current.addEventListener('touchstart', onTouchStart);
}
Expand Down

1 comment on commit 37f3aa2

@vercel
Copy link

@vercel vercel bot commented on 37f3aa2 Oct 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.