mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-06 22:40:14 -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 {CommentsEditorConfig, getEditorConfig} from './editor';
|
||||||
import {Editor, useEditor as useTiptapEditor} from '@tiptap/react';
|
import {Editor, useEditor as useTiptapEditor} from '@tiptap/react';
|
||||||
import {formatRelativeTime} from './helpers';
|
import {formatRelativeTime} from './helpers';
|
||||||
import {useAppContext} from '../AppContext';
|
import {useAppContext} from '../AppContext';
|
||||||
|
import {useCallback, useEffect, useMemo, useRef, useState} from 'react';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Execute a callback when a ref is set and unset.
|
* 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];
|
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) {
|
export function usePopupOpen(type: string) {
|
||||||
const {popup} = useAppContext();
|
const {popup} = useAppContext();
|
||||||
return popup?.type === type;
|
return popup?.type === type;
|
||||||
|
|
Loading…
Reference in a new issue