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

145
Views
My Input form won't allow edit using this function getDerivedStateFromProps Reactjs
constructor() {

        super();
        this.state={
            _id:"",
            Name:"",
            Age:"",
            isEdit:false
        }
    }

Old Code

componentWillReceiveProps(props){
        if(props.setForm._id != null){
            this.setState({
                isEdit:true,
            _id:props.setForm._id,
            Name:props.setForm.Name,
            Age:props.setForm.Age
            })
        }
    }

After changing

    static getDerivedStateFromProps(nextProps, prevState) {
    console.log(nextProps.setForm.Name);
    if(nextProps.setForm._id !== null)
    {
       return{
          isEdit:true,
          _id:nextProps.setForm._id,
         Name:nextProps.setForm.Name,
        Age:nextProps.setForm.Age
    
       } 
    }
      return null 
    }

I don't know what I did wrong. Form creation is working but when I click to edit the input field is not allowing me to edit. The error code is

index.js:1 Warning: A component is changing an uncontrolled input to be controlled. This is likely caused by the value changing from undefined to a defined value, which should not happen. Decide between using a controlled or uncontrolled input element for the lifetime of the component.

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!