mercredi 8 mars 2017

How to get values/properties from a react-bootstrap checkbox work?

I'm trying to use the react-bootstrap checkbox (http://ift.tt/2fbktgY) and I need to fire an event when it changes state. It would also be great to be able to programatically un/check it and/or tell if it is checked. Unfortunately when the code is transpiled and rendered it wraps the input in a div.

How can I find this in the dom and manipulate it?

My code looks similar to this:

import React, { PropTypes } from 'react';
import { Checkbox } from 'react-bootstrap';

const EditItem = (props) => {

  return (
    <div>
      <Checkbox style= >{props.itemLable}</Checkbox>
    </div>
  );
};

export default EditItem;

And the browser renders this:

...
<div class="checkbox" style="margin-left: 15px;">
  <label>
    <input type="checkbox">
  </label>
</div>
...

I see the inputRef prop in the documentation but I can't find any examples of this or get it to work myself.




Aucun commentaire:

Enregistrer un commentaire