mirror of
https://github.com/tiqi-group/pydase.git
synced 2025-04-20 00:10:03 +02:00
frontend: introduces useRenderCount hook
The useRenderCount hook contains all the necessary logic to count the re-render events. This reduces duplication and code complexity.
This commit is contained in:
parent
a5a957d290
commit
b1e6663c66
@ -3,6 +3,7 @@ import { runMethod } from "../socket";
|
|||||||
import { Form, Button, InputGroup, Spinner } from "react-bootstrap";
|
import { Form, Button, InputGroup, Spinner } from "react-bootstrap";
|
||||||
import { DocStringComponent } from "./DocStringComponent";
|
import { DocStringComponent } from "./DocStringComponent";
|
||||||
import { LevelName } from "./NotificationsComponent";
|
import { LevelName } from "./NotificationsComponent";
|
||||||
|
import { useRenderCount } from "../hooks/useRenderCount";
|
||||||
|
|
||||||
interface AsyncMethodProps {
|
interface AsyncMethodProps {
|
||||||
fullAccessPath: string;
|
fullAccessPath: string;
|
||||||
@ -30,14 +31,13 @@ export const AsyncMethodComponent = React.memo((props: AsyncMethodProps) => {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderCount = useRef(0);
|
const renderCount = useRenderCount();
|
||||||
const formRef = useRef(null);
|
const formRef = useRef(null);
|
||||||
const [spinning, setSpinning] = useState(false);
|
const [spinning, setSpinning] = useState(false);
|
||||||
const name = fullAccessPath.split(".").at(-1)!;
|
const name = fullAccessPath.split(".").at(-1)!;
|
||||||
const parentPath = fullAccessPath.slice(0, -(name.length + 1));
|
const parentPath = fullAccessPath.slice(0, -(name.length + 1));
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
renderCount.current++;
|
|
||||||
let message: string;
|
let message: string;
|
||||||
|
|
||||||
if (runningTask === null) {
|
if (runningTask === null) {
|
||||||
@ -66,9 +66,7 @@ export const AsyncMethodComponent = React.memo((props: AsyncMethodProps) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="component asyncMethodComponent" id={id}>
|
<div className="component asyncMethodComponent" id={id}>
|
||||||
{process.env.NODE_ENV === "development" && (
|
{process.env.NODE_ENV === "development" && <div>Render count: {renderCount}</div>}
|
||||||
<div>Render count: {renderCount.current}</div>
|
|
||||||
)}
|
|
||||||
<Form onSubmit={execute} ref={formRef}>
|
<Form onSubmit={execute} ref={formRef}>
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
<InputGroup.Text>
|
<InputGroup.Text>
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import React, { useEffect, useRef } from "react";
|
import React, { useEffect } from "react";
|
||||||
import { ToggleButton } from "react-bootstrap";
|
import { ToggleButton } from "react-bootstrap";
|
||||||
import { DocStringComponent } from "./DocStringComponent";
|
import { DocStringComponent } from "./DocStringComponent";
|
||||||
import { LevelName } from "./NotificationsComponent";
|
import { LevelName } from "./NotificationsComponent";
|
||||||
import { SerializedObject } from "../types/SerializedObject";
|
import { SerializedObject } from "../types/SerializedObject";
|
||||||
|
import { useRenderCount } from "../hooks/useRenderCount";
|
||||||
|
|
||||||
interface ButtonComponentProps {
|
interface ButtonComponentProps {
|
||||||
fullAccessPath: string;
|
fullAccessPath: string;
|
||||||
@ -29,11 +30,7 @@ export const ButtonComponent = React.memo((props: ButtonComponentProps) => {
|
|||||||
} = props;
|
} = props;
|
||||||
// const buttonName = props.mapping ? (value ? props.mapping[0] : props.mapping[1]) : name;
|
// const buttonName = props.mapping ? (value ? props.mapping[0] : props.mapping[1]) : name;
|
||||||
|
|
||||||
const renderCount = useRef(0);
|
const renderCount = useRenderCount();
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
renderCount.current++;
|
|
||||||
});
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
addNotification(`${fullAccessPath} changed to ${value}.`);
|
addNotification(`${fullAccessPath} changed to ${value}.`);
|
||||||
@ -51,9 +48,7 @@ export const ButtonComponent = React.memo((props: ButtonComponentProps) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={"component buttonComponent"} id={id}>
|
<div className={"component buttonComponent"} id={id}>
|
||||||
{process.env.NODE_ENV === "development" && (
|
{process.env.NODE_ENV === "development" && <div>Render count: {renderCount}</div>}
|
||||||
<div>Render count: {renderCount.current}</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<ToggleButton
|
<ToggleButton
|
||||||
id={`toggle-check-${id}`}
|
id={`toggle-check-${id}`}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import React, { useEffect, useRef } from "react";
|
import React from "react";
|
||||||
import { DocStringComponent } from "./DocStringComponent";
|
import { DocStringComponent } from "./DocStringComponent";
|
||||||
import { GenericComponent } from "./GenericComponent";
|
import { GenericComponent } from "./GenericComponent";
|
||||||
import { LevelName } from "./NotificationsComponent";
|
import { LevelName } from "./NotificationsComponent";
|
||||||
import { SerializedObject } from "../types/SerializedObject";
|
import { SerializedObject } from "../types/SerializedObject";
|
||||||
|
import { useRenderCount } from "../hooks/useRenderCount";
|
||||||
|
|
||||||
interface DictComponentProps {
|
interface DictComponentProps {
|
||||||
value: Record<string, SerializedObject>;
|
value: Record<string, SerializedObject>;
|
||||||
@ -15,18 +16,12 @@ interface DictComponentProps {
|
|||||||
export const DictComponent = React.memo((props: DictComponentProps) => {
|
export const DictComponent = React.memo((props: DictComponentProps) => {
|
||||||
const { value, docString, isInstantUpdate, addNotification, id } = props;
|
const { value, docString, isInstantUpdate, addNotification, id } = props;
|
||||||
|
|
||||||
const renderCount = useRef(0);
|
const renderCount = useRenderCount();
|
||||||
const valueArray = Object.values(value);
|
const valueArray = Object.values(value);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
renderCount.current++;
|
|
||||||
}, [props]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={"listComponent"} id={id}>
|
<div className={"listComponent"} id={id}>
|
||||||
{process.env.NODE_ENV === "development" && (
|
{process.env.NODE_ENV === "development" && <div>Render count: {renderCount}</div>}
|
||||||
<div>Render count: {renderCount.current}</div>
|
|
||||||
)}
|
|
||||||
<DocStringComponent docString={docString} />
|
<DocStringComponent docString={docString} />
|
||||||
{valueArray.map((item) => {
|
{valueArray.map((item) => {
|
||||||
return (
|
return (
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import React, { useEffect, useRef, useState } from "react";
|
import React, { useEffect } from "react";
|
||||||
import { InputGroup, Form, Row, Col } from "react-bootstrap";
|
import { InputGroup, Form, Row, Col } from "react-bootstrap";
|
||||||
import { DocStringComponent } from "./DocStringComponent";
|
import { DocStringComponent } from "./DocStringComponent";
|
||||||
import { LevelName } from "./NotificationsComponent";
|
import { LevelName } from "./NotificationsComponent";
|
||||||
import { SerializedObject } from "../types/SerializedObject";
|
import { SerializedObject } from "../types/SerializedObject";
|
||||||
|
import { useRenderCount } from "../hooks/useRenderCount";
|
||||||
|
|
||||||
export interface EnumSerialization {
|
export interface EnumSerialization {
|
||||||
type: "Enum" | "ColouredEnum";
|
type: "Enum" | "ColouredEnum";
|
||||||
@ -40,12 +41,8 @@ export const EnumComponent = React.memo((props: EnumComponentProps) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const renderCount = useRef(0);
|
|
||||||
const [enumValue, setEnumValue] = useState(value);
|
const [enumValue, setEnumValue] = useState(value);
|
||||||
|
const renderCount = useRenderCount();
|
||||||
useEffect(() => {
|
|
||||||
renderCount.current++;
|
|
||||||
});
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setEnumValue(() => {
|
setEnumValue(() => {
|
||||||
@ -56,9 +53,7 @@ export const EnumComponent = React.memo((props: EnumComponentProps) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={"component enumComponent"} id={id}>
|
<div className={"component enumComponent"} id={id}>
|
||||||
{process.env.NODE_ENV === "development" && (
|
{process.env.NODE_ENV === "development" && <div>Render count: {renderCount}</div>}
|
||||||
<div>Render count: {renderCount.current}</div>
|
|
||||||
)}
|
|
||||||
<Row>
|
<Row>
|
||||||
<Col className="d-flex align-items-center">
|
<Col className="d-flex align-items-center">
|
||||||
<InputGroup.Text>
|
<InputGroup.Text>
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import React, { useEffect, useRef, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Card, Collapse, Image } from "react-bootstrap";
|
import { Card, Collapse, Image } from "react-bootstrap";
|
||||||
import { DocStringComponent } from "./DocStringComponent";
|
import { DocStringComponent } from "./DocStringComponent";
|
||||||
import { ChevronDown, ChevronRight } from "react-bootstrap-icons";
|
import { ChevronDown, ChevronRight } from "react-bootstrap-icons";
|
||||||
import { LevelName } from "./NotificationsComponent";
|
import { LevelName } from "./NotificationsComponent";
|
||||||
|
import { useRenderCount } from "../hooks/useRenderCount";
|
||||||
|
|
||||||
interface ImageComponentProps {
|
interface ImageComponentProps {
|
||||||
fullAccessPath: string;
|
fullAccessPath: string;
|
||||||
@ -18,13 +19,9 @@ export const ImageComponent = React.memo((props: ImageComponentProps) => {
|
|||||||
const { fullAccessPath, value, docString, format, addNotification, displayName, id } =
|
const { fullAccessPath, value, docString, format, addNotification, displayName, id } =
|
||||||
props;
|
props;
|
||||||
|
|
||||||
const renderCount = useRef(0);
|
const renderCount = useRenderCount();
|
||||||
const [open, setOpen] = useState(true);
|
const [open, setOpen] = useState(true);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
renderCount.current++;
|
|
||||||
});
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
addNotification(`${fullAccessPath} changed.`);
|
addNotification(`${fullAccessPath} changed.`);
|
||||||
}, [props.value]);
|
}, [props.value]);
|
||||||
@ -43,7 +40,7 @@ export const ImageComponent = React.memo((props: ImageComponentProps) => {
|
|||||||
<Collapse in={open}>
|
<Collapse in={open}>
|
||||||
<Card.Body>
|
<Card.Body>
|
||||||
{process.env.NODE_ENV === "development" && (
|
{process.env.NODE_ENV === "development" && (
|
||||||
<p>Render count: {renderCount.current}</p>
|
<p>Render count: {renderCount}</p>
|
||||||
)}
|
)}
|
||||||
{format === "" && value === "" ? (
|
{format === "" && value === "" ? (
|
||||||
<p>No image set in the backend.</p>
|
<p>No image set in the backend.</p>
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
import React, { useEffect, useRef } from "react";
|
import React from "react";
|
||||||
import { DocStringComponent } from "./DocStringComponent";
|
import { DocStringComponent } from "./DocStringComponent";
|
||||||
import { GenericComponent } from "./GenericComponent";
|
import { GenericComponent } from "./GenericComponent";
|
||||||
import { LevelName } from "./NotificationsComponent";
|
import { LevelName } from "./NotificationsComponent";
|
||||||
import { SerializedObject } from "../types/SerializedObject";
|
import { SerializedObject } from "../types/SerializedObject";
|
||||||
|
import { useRenderCount } from "../hooks/useRenderCount";
|
||||||
|
|
||||||
interface ListComponentProps {
|
interface ListComponentProps {
|
||||||
value: SerializedObject[];
|
value: SerializedObject[];
|
||||||
@ -15,17 +16,11 @@ interface ListComponentProps {
|
|||||||
export const ListComponent = React.memo((props: ListComponentProps) => {
|
export const ListComponent = React.memo((props: ListComponentProps) => {
|
||||||
const { value, docString, isInstantUpdate, addNotification, id } = props;
|
const { value, docString, isInstantUpdate, addNotification, id } = props;
|
||||||
|
|
||||||
const renderCount = useRef(0);
|
const renderCount = useRenderCount();
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
renderCount.current++;
|
|
||||||
}, [props]);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={"listComponent"} id={id}>
|
<div className={"listComponent"} id={id}>
|
||||||
{process.env.NODE_ENV === "development" && (
|
{process.env.NODE_ENV === "development" && <div>Render count: {renderCount}</div>}
|
||||||
<div>Render count: {renderCount.current}</div>
|
|
||||||
)}
|
|
||||||
<DocStringComponent docString={docString} />
|
<DocStringComponent docString={docString} />
|
||||||
{value.map((item) => {
|
{value.map((item) => {
|
||||||
return (
|
return (
|
||||||
|
@ -3,6 +3,7 @@ import { runMethod } from "../socket";
|
|||||||
import { Button, Form } from "react-bootstrap";
|
import { Button, Form } from "react-bootstrap";
|
||||||
import { DocStringComponent } from "./DocStringComponent";
|
import { DocStringComponent } from "./DocStringComponent";
|
||||||
import { LevelName } from "./NotificationsComponent";
|
import { LevelName } from "./NotificationsComponent";
|
||||||
|
import { useRenderCount } from "../hooks/useRenderCount";
|
||||||
|
|
||||||
interface MethodProps {
|
interface MethodProps {
|
||||||
fullAccessPath: string;
|
fullAccessPath: string;
|
||||||
@ -21,7 +22,7 @@ export const MethodComponent = React.memo((props: MethodProps) => {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const renderCount = useRef(0);
|
const renderCount = useRenderCount();
|
||||||
const formRef = useRef(null);
|
const formRef = useRef(null);
|
||||||
|
|
||||||
const triggerNotification = () => {
|
const triggerNotification = () => {
|
||||||
@ -37,15 +38,9 @@ export const MethodComponent = React.memo((props: MethodProps) => {
|
|||||||
triggerNotification();
|
triggerNotification();
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
renderCount.current++;
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="component methodComponent" id={id}>
|
<div className="component methodComponent" id={id}>
|
||||||
{process.env.NODE_ENV === "development" && (
|
{process.env.NODE_ENV === "development" && <div>Render count: {renderCount}</div>}
|
||||||
<div>Render count: {renderCount.current}</div>
|
|
||||||
)}
|
|
||||||
<Form onSubmit={execute} ref={formRef}>
|
<Form onSubmit={execute} ref={formRef}>
|
||||||
<Button className="component" variant="primary" type="submit">
|
<Button className="component" variant="primary" type="submit">
|
||||||
{`${displayName} `}
|
{`${displayName} `}
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
import React, { useEffect, useState, useRef } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Form, InputGroup } from "react-bootstrap";
|
import { Form, InputGroup } from "react-bootstrap";
|
||||||
import { DocStringComponent } from "./DocStringComponent";
|
import { DocStringComponent } from "./DocStringComponent";
|
||||||
import "../App.css";
|
import "../App.css";
|
||||||
import { LevelName } from "./NotificationsComponent";
|
import { LevelName } from "./NotificationsComponent";
|
||||||
import { SerializedObject } from "../types/SerializedObject";
|
import { SerializedObject } from "../types/SerializedObject";
|
||||||
import { QuantityMap } from "../types/QuantityMap";
|
import { QuantityMap } from "../types/QuantityMap";
|
||||||
|
import { useRenderCount } from "../hooks/useRenderCount";
|
||||||
|
|
||||||
// TODO: add button functionality
|
// TODO: add button functionality
|
||||||
|
|
||||||
@ -171,7 +172,7 @@ export const NumberComponent = React.memo((props: NumberComponentProps) => {
|
|||||||
const [cursorPosition, setCursorPosition] = useState<number | null>(null);
|
const [cursorPosition, setCursorPosition] = useState<number | null>(null);
|
||||||
// Create a state for the input string
|
// Create a state for the input string
|
||||||
const [inputString, setInputString] = useState(value.toString());
|
const [inputString, setInputString] = useState(value.toString());
|
||||||
const renderCount = useRef(0);
|
const renderCount = useRenderCount();
|
||||||
|
|
||||||
const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
|
const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
|
||||||
const { key, target } = event;
|
const { key, target } = event;
|
||||||
@ -365,9 +366,7 @@ export const NumberComponent = React.memo((props: NumberComponentProps) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="component numberComponent" id={id}>
|
<div className="component numberComponent" id={id}>
|
||||||
{process.env.NODE_ENV === "development" && (
|
{process.env.NODE_ENV === "development" && <div>Render count: {renderCount}</div>}
|
||||||
<div>Render count: {renderCount.current}</div>
|
|
||||||
)}
|
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
{displayName && (
|
{displayName && (
|
||||||
<InputGroup.Text>
|
<InputGroup.Text>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useEffect, useRef, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { InputGroup, Form, Row, Col, Collapse, ToggleButton } from "react-bootstrap";
|
import { InputGroup, Form, Row, Col, Collapse, ToggleButton } from "react-bootstrap";
|
||||||
import { DocStringComponent } from "./DocStringComponent";
|
import { DocStringComponent } from "./DocStringComponent";
|
||||||
import { Slider } from "@mui/material";
|
import { Slider } from "@mui/material";
|
||||||
@ -6,6 +6,7 @@ import { NumberComponent, NumberObject } from "./NumberComponent";
|
|||||||
import { LevelName } from "./NotificationsComponent";
|
import { LevelName } from "./NotificationsComponent";
|
||||||
import { SerializedObject } from "../types/SerializedObject";
|
import { SerializedObject } from "../types/SerializedObject";
|
||||||
import { QuantityMap } from "../types/QuantityMap";
|
import { QuantityMap } from "../types/QuantityMap";
|
||||||
|
import { useRenderCount } from "../hooks/useRenderCount";
|
||||||
|
|
||||||
interface SliderComponentProps {
|
interface SliderComponentProps {
|
||||||
fullAccessPath: string;
|
fullAccessPath: string;
|
||||||
@ -23,7 +24,7 @@ interface SliderComponentProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const SliderComponent = React.memo((props: SliderComponentProps) => {
|
export const SliderComponent = React.memo((props: SliderComponentProps) => {
|
||||||
const renderCount = useRef(0);
|
const renderCount = useRenderCount();
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
const {
|
const {
|
||||||
fullAccessPath,
|
fullAccessPath,
|
||||||
@ -39,10 +40,6 @@ export const SliderComponent = React.memo((props: SliderComponentProps) => {
|
|||||||
id,
|
id,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
renderCount.current++;
|
|
||||||
});
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
addNotification(`${fullAccessPath} changed to ${value.value}.`);
|
addNotification(`${fullAccessPath} changed to ${value.value}.`);
|
||||||
}, [props.value]);
|
}, [props.value]);
|
||||||
@ -143,9 +140,7 @@ export const SliderComponent = React.memo((props: SliderComponentProps) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="component sliderComponent" id={id}>
|
<div className="component sliderComponent" id={id}>
|
||||||
{process.env.NODE_ENV === "development" && (
|
{process.env.NODE_ENV === "development" && <div>Render count: {renderCount}</div>}
|
||||||
<div>Render count: {renderCount.current}</div>
|
|
||||||
)}
|
|
||||||
|
|
||||||
<Row>
|
<Row>
|
||||||
<Col xs="auto" xl="auto">
|
<Col xs="auto" xl="auto">
|
||||||
|
@ -1,9 +1,10 @@
|
|||||||
import React, { useEffect, useRef, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Form, InputGroup } from "react-bootstrap";
|
import { Form, InputGroup } from "react-bootstrap";
|
||||||
import { DocStringComponent } from "./DocStringComponent";
|
import { DocStringComponent } from "./DocStringComponent";
|
||||||
import "../App.css";
|
import "../App.css";
|
||||||
import { LevelName } from "./NotificationsComponent";
|
import { LevelName } from "./NotificationsComponent";
|
||||||
import { SerializedObject } from "../types/SerializedObject";
|
import { SerializedObject } from "../types/SerializedObject";
|
||||||
|
import { useRenderCount } from "../hooks/useRenderCount";
|
||||||
|
|
||||||
// TODO: add button functionality
|
// TODO: add button functionality
|
||||||
|
|
||||||
@ -31,13 +32,9 @@ export const StringComponent = React.memo((props: StringComponentProps) => {
|
|||||||
id,
|
id,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
const renderCount = useRef(0);
|
const renderCount = useRenderCount();
|
||||||
const [inputString, setInputString] = useState(props.value);
|
const [inputString, setInputString] = useState(props.value);
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
renderCount.current++;
|
|
||||||
}, [isInstantUpdate, inputString, renderCount]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Only update the inputString if it's different from the prop value
|
// Only update the inputString if it's different from the prop value
|
||||||
if (props.value !== inputString) {
|
if (props.value !== inputString) {
|
||||||
@ -86,9 +83,7 @@ export const StringComponent = React.memo((props: StringComponentProps) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="component stringComponent" id={id}>
|
<div className="component stringComponent" id={id}>
|
||||||
{process.env.NODE_ENV === "development" && (
|
{process.env.NODE_ENV === "development" && <div>Render count: {renderCount}</div>}
|
||||||
<div>Render count: {renderCount.current}</div>
|
|
||||||
)}
|
|
||||||
<InputGroup>
|
<InputGroup>
|
||||||
<InputGroup.Text>
|
<InputGroup.Text>
|
||||||
{displayName}
|
{displayName}
|
||||||
|
11
frontend/src/hooks/useRenderCount.ts
Normal file
11
frontend/src/hooks/useRenderCount.ts
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import { useRef, useEffect } from "react";
|
||||||
|
|
||||||
|
export function useRenderCount() {
|
||||||
|
const count = useRef(0);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
count.current += 1;
|
||||||
|
});
|
||||||
|
|
||||||
|
return count.current;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user