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