session-desktop/ts/components/session/SessionRadio.tsx

43 lines
770 B
TypeScript
Raw Normal View History

2020-01-14 07:42:04 +01:00
import React from 'react';
import classNames from 'classnames';
interface Props {
label: string;
active: boolean;
}
interface State {
active: boolean;
}
export class SessionRadio extends React.PureComponent<Props, State> {
constructor(props: any) {
super(props);
this.clickHandler = this.clickHandler.bind(this);
this.state = {
active: this.props.active,
}
}
public render() {
const active = this.state.active;
const { label } = this.props;
return (
<div className={classNames('session-radio', active && 'checked')}>
<input type="radio" />
<label>{ label } </label>
</div>
);
}
private clickHandler() {
this.setState({
active: !this.state.active,
});
}
}