jeudi 6 septembre 2018

MaterialUI dynamically create checkboxes

I'm getting started on React and MaterialUI by trying to build a simple group of checkboxes. How would I go about trying to dynamically add checkboxes to a component?

I'm thinking that if I pass in a prop like numCheckboxes=3, into CheckboxesGroup, I should define a function that will add 3 <Checkbox /> into the document.

Am I on the right track by utilizing componentDidMount() to call on a function like addCheckbox() 3 times where addCheckbox() is something like

var label = document.createElement("label");
label.appendChild(<Checkbox />);

Thanks for your help!




Aucun commentaire:

Enregistrer un commentaire