mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-30 22:34:01 -05:00
Removed unused useSecondUpdate hook in comments-ui
no issue - left over after cleanup of secondary form code
This commit is contained in:
parent
972cc82958
commit
5ec9f59411
1 changed files with 1 additions and 18 deletions
|
@ -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<T>(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;
|
||||
|
|
Loading…
Reference in a new issue