Skip to content

Commit 321be8c

Browse files
committed
Remove useLayoutEffect
1 parent 03a3b15 commit 321be8c

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/components/Datepicker.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import React, {useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState} from "react";
1+
import React, {useCallback, useEffect, useMemo, useRef, useState} from "react";
22
import dayjs from "dayjs";
33
import {formatDate, nextMonth, previousMonth} from "../helpers";
44
import Input from "../components/Input";
@@ -131,7 +131,7 @@ const Datepicker: React.FC<Props> = ({primaryColor = "blue", value = null, onCha
131131
}, [secondDate, secondGotoDate]);
132132

133133
// UseEffects & UseLayoutEffect
134-
useLayoutEffect(() => {
134+
useEffect(() => {
135135
const container = containerRef.current;
136136
const calendarContainer = calendarContainerRef.current;
137137
const arrow = arrowRef.current;

src/components/Input.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import dayjs from "dayjs";
22
import {CloseIcon, DateIcon} from "./utils";
3-
import React, {useCallback, useContext, useLayoutEffect, useRef} from "react";
3+
import React, {useCallback, useContext, useEffect, useRef} from "react";
44
import {BORDER_COLOR, RING_COLOR} from "../constants";
55
import {dateIsValid} from "../helpers";
66
import DatepickerContext from "../contexts/DatepickerContext";
@@ -41,7 +41,7 @@ const Input: React.FC = () => {
4141
}, [changeDatepickerValue, changeDayHover, changeInputText, hideDatepicker]);
4242

4343
// UseEffects && UseLayoutEffect
44-
useLayoutEffect(() => {
44+
useEffect(() => {
4545
const button = buttonRef?.current;
4646

4747
function focusInput (e: Event) {
@@ -76,7 +76,7 @@ const Input: React.FC = () => {
7676
};
7777
}, [changeDatepickerValue, changeDayHover, changeInputText, dayHover, inputText, period.end, period.start]);
7878

79-
useLayoutEffect(() => {
79+
useEffect(() => {
8080
const div = calendarContainer?.current;
8181
const input = inputRef.current;
8282

0 commit comments

Comments
 (0)