Skip to content

Instantly share code, notes, and snippets.

@mlms13
Created May 22, 2018 21:57
Show Gist options
  • Save mlms13/99b634fbbc0a8e2c1c84029803ea1170 to your computer and use it in GitHub Desktop.
Save mlms13/99b634fbbc0a8e2c1c84029803ea1170 to your computer and use it in GitHub Desktop.
/* Importing is just renaming values that are already in scope */
let map = Belt.Array.map;
let reactDom = ReasonReact.createDomElement;
let reactString = ReasonReact.string;
/* You can also alias entire modules */
module RadioButton = Huey.Form.RadioButton;
/* Make the component */
let component = ReasonReact.statelessComponent("RadioButtonGroup");
let make = (~items, ~show, ~eq, ~onChange, ~value, ~label, _children) => {
...component,
render: _self => {
let children = items |. map(item => {
let selected = eq(item, value);
<RadioButton item show selected onChange />
});
<div className="huey-radio-group">
<div className="huey-form-control-label">{ reactString(label) }</div>
reactDom("div", ~props={ "className": "huey-radio-group-items" }, children)
</div>
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment