import { Dispatch, SetStateAction, ChangeEvent, useMemo } from 'react' import { Label, Input } from 'theme-ui' import detachDebugger from '../../utils/detachDebugger' import debounce from 'lodash.debounce' interface DebouncedInputProps { name: string title: string value: string setValue: Dispatch> onChange: () => void mb?: string } const DebouncedInput = ({ name, title, value, setValue, onChange, mb, }: DebouncedInputProps) => { const debouncedChangeHandler = useMemo( () => debounce((e) => { detachDebugger() chrome.storage.local.set({ [name]: e.target.value }) }, 300), [name] ) const changeInputText = (e: ChangeEvent) => { setValue(e.target.value) onChange() debouncedChangeHandler(e) } return ( <> ) } export default DebouncedInput