Refactor table size picker (#1662)

Signed-off-by: Tilman Vatteroth <git@tilmanvatteroth.de>
This commit is contained in:
Tilman Vatteroth 2021-12-02 23:55:16 +01:00 committed by GitHub
parent b68a55aa94
commit 9874d54404
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 281 additions and 160 deletions

View file

@ -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