You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
	
	
		
			
				
					
						
							|  |  |  | import React, { useEffect, useState } from 'react'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import { SessionRadio } from './SessionRadio'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | interface Props { | 
					
						
							|  |  |  |   // tslint:disable: react-unused-props-and-state
 | 
					
						
							|  |  |  |   initialItem: string; | 
					
						
							|  |  |  |   items: Array<any>; | 
					
						
							|  |  |  |   group: string; | 
					
						
							|  |  |  |   onClick: (selectedValue: string) => any; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export const SessionRadioGroup = (props: Props) => { | 
					
						
							|  |  |  |   const [activeItem, setActiveItem] = useState(''); | 
					
						
							|  |  |  |   const { items, group, initialItem } = props; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   useEffect(() => { | 
					
						
							|  |  |  |     setActiveItem(initialItem); | 
					
						
							|  |  |  |   }, []); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return ( | 
					
						
							|  |  |  |     <div className="session-radio-group"> | 
					
						
							|  |  |  |       <fieldset id={group}> | 
					
						
							|  |  |  |         {items.map(item => { | 
					
						
							|  |  |  |           const itemIsActive = item.value === activeItem; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           return ( | 
					
						
							|  |  |  |             <SessionRadio | 
					
						
							|  |  |  |               key={item.value} | 
					
						
							|  |  |  |               label={item.label} | 
					
						
							|  |  |  |               active={itemIsActive} | 
					
						
							|  |  |  |               value={item.value} | 
					
						
							|  |  |  |               group={group} | 
					
						
							|  |  |  |               onClick={(value: string) => { | 
					
						
							|  |  |  |                 setActiveItem(value); | 
					
						
							|  |  |  |                 props.onClick(value); | 
					
						
							|  |  |  |               }} | 
					
						
							|  |  |  |             /> | 
					
						
							|  |  |  |           ); | 
					
						
							|  |  |  |         })} | 
					
						
							|  |  |  |       </fieldset> | 
					
						
							|  |  |  |     </div> | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | }; |