Lazy initialise the “isFieldVisible” state
This commit is contained in:
parent
ebca77947c
commit
6c5c03b8c1
|
@ -34,7 +34,7 @@ const Address2Field = < T extends AddressFormValues | ContactFormValues >( {
|
||||||
const isFieldRequired = field ? field.required : false;
|
const isFieldRequired = field ? field.required : false;
|
||||||
|
|
||||||
const [ isFieldVisible, setFieldVisible ] = useState(
|
const [ isFieldVisible, setFieldVisible ] = useState(
|
||||||
hasFieldValue || isFieldRequired
|
() => hasFieldValue || isFieldRequired
|
||||||
);
|
);
|
||||||
|
|
||||||
const toggleFieldVisibility = useCallback(
|
const toggleFieldVisibility = useCallback(
|
||||||
|
|
Loading…
Reference in New Issue