Prevent double rendering in strict mode

The double invocation during dev mode, while harmless, is confusing, so add an
additional small check to insure this only runs once.
This commit is contained in:
Manav Rathi 2024-04-04 14:25:04 +05:30
parent 712b99b8f3
commit 608cb6c85e
No known key found for this signature in database

View file

@ -1,12 +1,15 @@
import React, { useEffect } from "react";
import React, { useEffect, useRef, useState } from "react";
import { Container } from "./components/Container";
import { parseAndHandleRequest } from "./services/billing-service";
import S from "./utils/strings";
export const App: React.FC = () => {
const [failed, setFailed] = React.useState(false);
const [failed, setFailed] = useState(false);
const once = useRef(false);
useEffect(() => {
if (once.current) return;
once.current = true;
parseAndHandleRequest().catch(() => {
setFailed(true);
});