import React, { useEffect } from 'react'; // Get previous state value export const usePrevious = (value: T) => { const ref = React.useRef(undefined); React.useEffect(() => { ref.current = value; }, [value]); return ref.current; }; export function usePropsOrInternalState( initialState: T, state: T | undefined, setState: ((val: T) => void) | undefined ): [T, (val: T) => void] { const [internalState, setInternalState] = React.useState(initialState); return [state || internalState, setState || setInternalState]; } export const useDeprecation = (message: string, cond = true) => { useEffect(() => { // eslint-disable-next-line no-console if (cond) { console.warn(message); } }, [message, cond]); };