mardi 1 septembre 2020

react, How to change existing data with data reset in if statement

 const onOk = values => {
        const { patient } = values;
        const { pid, name, gender, age, birth } = patient;
        const birth_date = Moment(birth).format(dateFormat);
            
        if (pid != editpid) {
            const pid = { editpid }
            console.log(pid)
        }
        if (name != editname) {
            const name = { editname }
            console.log(name)
        }
        if (gender != editgender) {
            const gender = { editgender }
            console.log(gender)
        }
        if (age != editage) {
            const age = { editage }
            console.log(age)
        }
        console.log(pid, name, gender, age, birth)
    }

I can not speak English very well.

Currently, the if statement calls the patient's pid, name, etc., and attempts to reset data such as pid, name, etc. after comparison.

The data is changed in the if statement, but the changed data is not entered into the patient data and cannot be reset.

How can I put reset data into patient data?

Thanks in advance to those who respond.

Aucun commentaire:

Enregistrer un commentaire