Fix useEffect effenceincy,
This commit is contained in:
@@ -14,9 +14,7 @@ const CustomButton = ({ text, link, type }: CustomButtonProps): JSX.Element => {
|
|||||||
return (
|
return (
|
||||||
<MotionBox whileHover={{ scale: 1.1 }} whileTap={{ scale: 0.9 }}>
|
<MotionBox whileHover={{ scale: 1.1 }} whileTap={{ scale: 0.9 }}>
|
||||||
<Link href={link} target="_blank" rel="noopener">
|
<Link href={link} target="_blank" rel="noopener">
|
||||||
<Button variant={type}>
|
<Button variant={type}>{text}</Button>
|
||||||
{text}
|
|
||||||
</Button>
|
|
||||||
</Link>
|
</Link>
|
||||||
</MotionBox>
|
</MotionBox>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -13,10 +13,7 @@ const Patreon = (): JSX.Element => {
|
|||||||
target="_blank"
|
target="_blank"
|
||||||
rel="noopener"
|
rel="noopener"
|
||||||
>
|
>
|
||||||
<Button
|
<Button variant="patreon" leftIcon={<Icon icon="ri:patreon-fill" />}>
|
||||||
variant="patreon"
|
|
||||||
leftIcon={<Icon icon="ri:patreon-fill" />}
|
|
||||||
>
|
|
||||||
{"Fund The App"}
|
{"Fund The App"}
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ const Calender = ({
|
|||||||
const selectedDate: SelectedDateInfo = useAppSelector(
|
const selectedDate: SelectedDateInfo = useAppSelector(
|
||||||
(state) => state.calender.selectedDateInfo
|
(state) => state.calender.selectedDateInfo
|
||||||
);
|
);
|
||||||
const { layout, title } = selectedDate;
|
const { layout, title, date: currentSelectedDateStr } = selectedDate;
|
||||||
|
|
||||||
const currDateObj = new Date(currDate);
|
const currDateObj = new Date(currDate);
|
||||||
|
|
||||||
@@ -33,9 +33,12 @@ const Calender = ({
|
|||||||
|
|
||||||
if (year > 0 && month > 0 && day > 0) {
|
if (year > 0 && month > 0 && day > 0) {
|
||||||
const generatedDate: Date = new Date(year, month - 1, day);
|
const generatedDate: Date = new Date(year, month - 1, day);
|
||||||
|
const currSelectedDateObj = new Date(currentSelectedDateStr);
|
||||||
const dateString: string = generatedDate.toJSON();
|
const dateString: string = generatedDate.toJSON();
|
||||||
|
|
||||||
|
if (!isSameDay(currSelectedDateObj, generatedDate)) {
|
||||||
dispatch(updateMonth(dateString));
|
dispatch(updateMonth(dateString));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
console.warn("Invalid date format: ", newDate);
|
console.warn("Invalid date format: ", newDate);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ const CalenderExample = ({ type }: CalenderExampleProps): JSX.Element => {
|
|||||||
|
|
||||||
// TODO: Disable the days that shouldn't have a function to prevent edits on add example and add to current date on the edit example.
|
// TODO: Disable the days that shouldn't have a function to prevent edits on add example and add to current date on the edit example.
|
||||||
|
|
||||||
const currDateObj: Date = new Date();
|
const currDateStr: string = useAppSelector(state => state.calender.currDate);
|
||||||
|
const currDateObj: Date = new Date(currDateStr);
|
||||||
const isLoading = false;
|
const isLoading = false;
|
||||||
|
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
@@ -25,7 +26,7 @@ const CalenderExample = ({ type }: CalenderExampleProps): JSX.Element => {
|
|||||||
const selectedDate: SelectedDateInfo = useAppSelector(
|
const selectedDate: SelectedDateInfo = useAppSelector(
|
||||||
(state) => state.calender.selectedDateInfo
|
(state) => state.calender.selectedDateInfo
|
||||||
);
|
);
|
||||||
const { layout } = selectedDate;
|
const { layout, date: currSelectedDateStr } = selectedDate;
|
||||||
|
|
||||||
// * Stickers * //
|
// * Stickers * //
|
||||||
|
|
||||||
@@ -45,8 +46,13 @@ const CalenderExample = ({ type }: CalenderExampleProps): JSX.Element => {
|
|||||||
const { month, weekdays } = currMonth;
|
const { month, weekdays } = currMonth;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
dispatch(updateMonth(new Date().toJSON()));
|
const currDateObj: Date = new Date(currDateStr);
|
||||||
}, [dispatch]);
|
const currSelectedDateOj: Date = new Date(currSelectedDateStr);
|
||||||
|
|
||||||
|
if (!isSameDay(currDateObj, currSelectedDateOj)) {
|
||||||
|
dispatch(updateMonth(currDateObj.toJSON()));
|
||||||
|
}
|
||||||
|
}, [currDateStr, currSelectedDateStr, dispatch]);
|
||||||
|
|
||||||
// * The current week * //
|
// * The current week * //
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,9 @@ const Tutorial = ({
|
|||||||
setTutorialComplete,
|
setTutorialComplete,
|
||||||
setTempTutorialComplete
|
setTempTutorialComplete
|
||||||
}: TutorialProps): JSX.Element => {
|
}: TutorialProps): JSX.Element => {
|
||||||
const rememberComplete = useAppSelector(state => state.tutorial.rememberCompleted);
|
const rememberComplete = useAppSelector(
|
||||||
|
(state) => state.tutorial.rememberCompleted
|
||||||
|
);
|
||||||
const dispatch = useAppDispatch();
|
const dispatch = useAppDispatch();
|
||||||
|
|
||||||
const handleComplete = (): void => {
|
const handleComplete = (): void => {
|
||||||
|
|||||||
Reference in New Issue
Block a user