I have a btn that depends of errors obj, if there are errors in obj btn will be disabled disabled={Object.keys(errors).length > 0 ? true : false} I'm adding the error in another component, but I don't see the rerender in this component I exactly know that error added in errors, but button not disabled
I have a form in the form I have a Navigation component
<Navigation
toolName={toolName}
setDropzoneError={setDropzoneError}
isSubmit={isSubmit}
errors={errors}
/>
in this component there is a btn that should looks like disabled or nor dependes of amoun errors here this depending disabled={Object.keys(errors).length > 0 ? true : false}
also I have a component in this form
<DescriptionAndFiles
toolName={toolName}
onFilesSubmit={onFilesSubmit}
register={register}
errors={errors}
dropzoneError={dropzoneError}
parentTask={parentTask}
downloadFiles={downloadFiles}
handleSpChange={handleSpChange}
setDropError={setDropError}
/>
in DescriptionAndFile I have component
<CustomDropzone
toolName={toolName}
handleFile={onFilesSubmit}
dropzoneError={dropzoneError}
prefetchedFiles={addedPrefetch}
setDropError={setDropError}
/>
if I dropzone is require, but there is not file in drop zone I print "mistake" and turn dropError to true
if (filesInfo.filesOption === FilesOption.Required) {
if (constFileList.length === 0 && dropzoneError) {
dropzoneStyle = `${styles.dropzoneDefault} ${styles.dropzoneNoFiles}`;
console.log('mistake')
setDropError(true)
requiredFieldMessage = (
<p className={errorStyles.errorText}>{intl.get('REQUIRED_FIELD')}</p>
);
} else {
console.log('no mistake')
setDropError(false)
dropzoneStyle = styles.dropzoneDefault;
}
}
so, when I add file I see in console message 'no mistake', when I delete the file from dropzone I see message 'mistake', but button don't change