💥 (breaking) replace useEffect with runOnce hook

using useRunOnce instead of using useEffect in a primitive way just to avoid React strict mode.
This commit is contained in:
2025-09-02 11:20:42 +07:00
parent f95da1771e
commit 64a9cf1cf3

View File

@ -1,18 +1,15 @@
"use client"; "use client";
import React from "react";
import { CircularProgress } from "@heroui/react"; import { CircularProgress } from "@heroui/react";
import React, { useEffect, useRef } from "react";
import { SendCallbackToServer } from "../lib/sendCallbackToServer"; import { SendCallbackToServer } from "../lib/sendCallbackToServer";
import { useParams } from "next/navigation"; import { useParams } from "next/navigation";
import { useRunOnce } from "@/shared/hooks/useRunOnce";
const LoadingProcess = () => { const LoadingProcess = () => {
const params = useParams(); const params = useParams();
const calledRef = useRef(false);
useEffect(() => {
if (calledRef.current) return;
calledRef.current = true;
(async () => { useRunOnce("forwardCallbackResponseToBackend", async () => {
try { try {
await SendCallbackToServer( await SendCallbackToServer(
window.location.search, window.location.search,
@ -22,8 +19,7 @@ const LoadingProcess = () => {
} catch (error) { } catch (error) {
console.log(error); console.log(error);
} }
})(); });
}, []);
return ( return (
<div className="w-full flex flex-col items-center text-center mt-[26vh]"> <div className="w-full flex flex-col items-center text-center mt-[26vh]">
<CircularProgress aria-label="Loading..." size="lg" /> <CircularProgress aria-label="Loading..." size="lg" />