Skip to content

Commit

Permalink
Added in onChange event and className extending (#183)
Browse files Browse the repository at this point in the history
* Added in onChange event and className extending

* Remove listeners before destroying component
  • Loading branch information
MobiusHorizons authored and filoozom committed Jul 31, 2017
1 parent dddb0dd commit 0dd7f51
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion IconToggle/IconToggle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,19 @@ export default class IconToggle extends MaterialComponent {
constructor() {
super();
this.componentName = "icon-toggle";
this._onChange = this._onChange.bind(this);
}
_onChange(e) {
if (this.props.onChange) {
this.props.onChange(e);
}
}
componentDidMount() {
this.MDComponent = new MDCIconToggle(this.control);
this.MDComponent.listen("MDCIconToggle:change", this._onChange);
}
componentWillUnmount() {
this.MDComponent.unlisten("MDCIconToggle:change", this._onChange);
this.MDComponent.destroy && this.MDComponent.destroy();
}
materialDom(props) {
Expand All @@ -24,7 +32,7 @@ export default class IconToggle extends MaterialComponent {
return (
<i
{...props}
className="material-icons"
className={"material-icons " + props.className || ""}
ref={control => {
this.control = control;
}}
Expand Down

0 comments on commit 0dd7f51

Please sign in to comment.