import React from 'react'; import { SessionRadio } from './SessionRadio'; interface Props { initalItem: string; items: Array; group: string; onClick?: any; } interface State { activeItem: string; } export class SessionRadioGroup extends React.PureComponent { public static defaultProps = { onClick: () => null, }; constructor(props: any) { super(props); this.clickHandler = this.clickHandler.bind(this); this.state = { activeItem: this.props.initalItem, }; } public render() { const { items, group } = this.props; return (
{items.map(item => { const itemIsActive = item.value === this.state.activeItem; return ( ); })}
); } private clickHandler() { if (this.props.onClick) { this.props.onClick(); } } }