Lazy initialise the “isFieldVisible” state

This commit is contained in:
Niels Lange 2024-05-17 16:59:11 +07:00
parent ebca77947c
commit 6c5c03b8c1
No known key found for this signature in database
GPG Key ID: 1C3F03249476BAC0
1 changed files with 1 additions and 1 deletions

View File

@ -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(