vendredi 14 mai 2021

show correct value for checkbox in editing mode in reactjs

I have ran into a problem, I am trying to show the correct value in checkbox in editing mode right now it shows false all the time how to do this??, here is my code...

      ) : currentlyEditing && y.type === 'checkbox' ? (
        <Checkbox
          style=
          name={y.prop}
          type={y.type}
          value={x[y.prop]}
          checked={x[y.prop]}
          disabled={false}
          onChange={(e) => handleChange(e, y.prop, i)}
        />
      ) : !currentlyEditing && y.type === 'checkbox' ? (
        <Checkbox
          style=
          name={y.prop}
          type={y.type}
          value={x[y.prop]}
          checked={x[y.prop]}
          disabled={true}
        />
      )

and the code for the table prop is... { name: 'Meds', prop: 'chkMedsB', type: 'checkbox', },

what I want it to do is if the checkbox is checked when not in editing mode to have it show checked in editing mode, right now it shows checkbox as un checked in editing mode no mater what... can anyone help...




Aucun commentaire:

Enregistrer un commentaire