vendredi 23 juin 2017

How can I preserve a checkbox value type?

I am working in jsx / react, but I imagine this is html5 behaviour.

<input
  type="checkbox"
  name={name}
  value={value}
  checked={checked}
  disabled={disabled}
  onChange={this.handleChange}
/>

If the value is a boolean or a number it get's converted to a string. E.g. 'false' or '1'.

Is there a way to preserve the type, or is there a more idiomatic way to re-establish the type than JSON.parse()?




Aucun commentaire:

Enregistrer un commentaire