interface StateInputProps { state: PrimitiveAtom; className?: string; } const NumberStateInput: FC> = ( props: StateInputProps ) => { const { state, className } = props; const [number, setNumber] = useAtom(state); const handleChange = useCallback( (e: ChangeEvent) => { const re = /^\d*$/; const v = e.target.value; if (v === '') { setNumber(null); } else if (re.test(v)) { setNumber(parseInt(v)); } }, [setNumber] ); return ( ); };