From 5ec9f594110ace57c284bc5ccf8ae579675b69df Mon Sep 17 00:00:00 2001 From: Kevin Ansfield Date: Mon, 9 Dec 2024 14:47:22 +0000 Subject: [PATCH] Removed unused useSecondUpdate hook in comments-ui no issue - left over after cleanup of secondary form code --- apps/comments-ui/src/utils/hooks.ts | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/apps/comments-ui/src/utils/hooks.ts b/apps/comments-ui/src/utils/hooks.ts index 42aff108b7..bdf0b4f8db 100644 --- a/apps/comments-ui/src/utils/hooks.ts +++ b/apps/comments-ui/src/utils/hooks.ts @@ -1,8 +1,8 @@ -import React, {useCallback, useEffect, useMemo, useRef, useState} from 'react'; import {CommentsEditorConfig, getEditorConfig} from './editor'; import {Editor, useEditor as useTiptapEditor} from '@tiptap/react'; import {formatRelativeTime} from './helpers'; import {useAppContext} from '../AppContext'; +import {useCallback, useEffect, useMemo, useRef, useState} from 'react'; /** * Execute a callback when a ref is set and unset. @@ -28,23 +28,6 @@ export function useRefCallback(setup: (element: T) => void, clear?: (element: return [ref, setRef]; } -/** - * Sames as useEffect, but ignores the first mounted call and the first update (so first 2 calls ignored) - * @param {Same} fn - * @param {*} inputs -*/ -export function useSecondUpdate(fn: () => void, inputs: React.DependencyList) { - const didMountRef = useRef(0); - - useEffect(() => { - if (didMountRef.current >= 2) { - return fn(); - } - didMountRef.current += 1; - // We shouldn't listen for fn changes, so ignore exhaustive-deps - }, inputs); -} - export function usePopupOpen(type: string) { const {popup} = useAppContext(); return popup?.type === type;