mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-05-21 10:45:20 -04:00
Refactor table size picker (#1662)
Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
parent
b68a55aa94
commit
9874d54404
9 changed files with 281 additions and 160 deletions
|
@ -8,11 +8,8 @@ import equal from 'fast-deep-equal'
|
|||
import type { MutableRefObject } from 'react'
|
||||
import { useEffect, useRef } from 'react'
|
||||
|
||||
export const useOnRefChange = <T>(
|
||||
reference: MutableRefObject<T | undefined>,
|
||||
onChange?: (newValue?: T) => void
|
||||
): void => {
|
||||
const lastValue = useRef<T | undefined>()
|
||||
export const useOnRefChange = <T>(reference: MutableRefObject<T>, onChange?: (newValue: T) => void): void => {
|
||||
const lastValue = useRef<T>()
|
||||
useEffect(() => {
|
||||
if (onChange && !equal(reference, lastValue.current)) {
|
||||
lastValue.current = reference.current
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue