Auto-scroll the left pane less frequently

This commit is contained in:
Evan Hahn 2021-03-18 19:22:17 -05:00 committed by Josh Perez
commit c97bb0feee
5 changed files with 43 additions and 59 deletions

View file

@ -5,6 +5,13 @@ import * as React from 'react';
import { ActionCreatorsMapObject, bindActionCreators } from 'redux';
import { useDispatch } from 'react-redux';
export function usePrevious<T>(initialValue: T, currentValue: T): T {
const previousValueRef = React.useRef<T>(initialValue);
const result = previousValueRef.current;
previousValueRef.current = currentValue;
return result;
}
// Restore focus on teardown
export const useRestoreFocus = (
// The ref for the element to receive initial focus