useEffect(() => {
if (dataForm) {
setValue("amount", dataForm.amount);
setValue("term", dataForm.term);
setValue("lastName", dataForm.lastName);
setValue("firstName", dataForm.firstName);
setValue("middleName", dataForm.middleName);
setValue("numberDate", dataForm.dateOfBirth);
setValue("numberPhone", dataForm.numberPhone);
setValue("email", dataForm.email);
setValue("checkbox", dataForm.checkbox);
}
}, [dataForm, setValue]);
setPassport({...passport, placeOfIssue: value})
, а что-то вроде такого:useEffect (() => {
PlaceOfIssueScript(
(value) => setPassport(prevState => {
return {...prevState, placeOfIssue: value }
}),
(value) => setPassport(prevState => {
return {...prevState, ouCode: value.replace(/[^0-9]/g, '') }
}),
setStatusSelec
)
}, [passport])
const setCharAt = (str,index,chr) => {
if(index > str.length-1) return str;
str.substring(0,index) + chr + str.substring(index+1);
}
export const formatNumber = (string) => {
if (string.charAt(0) === "8" || string.charAt(0) === "7") {
return string = setCharAt(string, 0, "")
} else if ((string.charAt(0) === "8" || string.charAt(0) === "7") && (string.charAt(1) === "8" || string.charAt(1) === "7")) {
string = setCharAt(string, 0, "")
return string = setCharAt(string, 1, "")
}
}
<IMaskInput
value={convertObjectValues(valueSum, true)}
mask={"a d"}
blocks={{ d: { mask: "₽" }, a:{mask: Number, thousandsSeparator: ' ', min: 1500, max: 15000} }}
lazy={false}
placeholder={valueSum}
unmask={true}
onAccept={ (value) => setValueSum(value) }
onBlur={handlerBlurSum}
onPointerLeave={handlerBlurSum}
onClick={handlerBlurSum}
/>