Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

106
Views
I can't rerender component to disable btn in react

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

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!