Reactjs 使用onAccept属性反应Imask输入组件重新呈现问题
亲爱的,有人能建议我如何禁用onAccept属性组件的重新呈现吗Reactjs 使用onAccept属性反应Imask输入组件重新呈现问题,reactjs,converters,Reactjs,Converters,亲爱的,有人能建议我如何禁用onAccept属性组件的重新呈现吗 <IMaskInput mask={Number} radix="." scale={currency === "dgc" ? 6 : 8} signed={false} thousandsSeparator="," value={amount} unmask="typed" onA
<IMaskInput
mask={Number}
radix="."
scale={currency === "dgc" ? 6 : 8}
signed={false}
thousandsSeparator=","
value={amount}
unmask="typed"
onAccept={(typedValue) => onChangeAmount(typedValue)}
className={styles.cardInput}
/>
谢谢大家!
const [amount, setAmount] = useState();
const [inputInLeftField, setInputInLeftField] = useState(true);
let toAmount, fromAmount;
if (inputInLeftField) {
fromAmount = amount;
toAmount = amount * 2;
} else {
toAmount = amount;
fromAmount = amount / 2;
}
const fromAmountChangeHandler = (value) => {
setAmount(value);
setInputInLeftField(true);
};
const toAmountChangeHandler = (value) => {
setAmount(value);
setInputInLeftField(false);
};