import React, { Component, useState, useRef, useEffect } from 'react'; import { Input } from '@alifd/next'; interface RsStringSetterProps { value?: string | number | undefined; onChange?: (value: string | number | undefined) => void; placeholder?: string | undefined; } const RsStringSetter: React.FC = (props) => { const { onChange, placeholder, value } = props; const [inputValue, setInputValue] = useState(value); const timer = useRef(); const handleChange = (val: string | number | undefined) => { if (timer.current) { clearTimeout(timer.current); } timer.current = setTimeout(() => { onChange?.(val); }, 350); }; useEffect(() => { return () => { if (timer.current) { clearTimeout(timer.current); } }; }, []); useEffect(() => { setInputValue(value); }, [value]); return ( { setInputValue(val); handleChange(val); }} style={{ width: '100%' }} /> ); }; export default class extends Component { static displayName = 'RsStringSetter'; render() { return ; } }