UNPKG

fk-react-ui-components

Version:

Step 1 : Create a file in [ Seeds / Plants / Trees ] <br> Step 2 : It should export an Object with component name and story Component [Refer other components] <br> Step 3 : Story Component should return a react component <br> Step 3 : Created file should

45 lines (38 loc) 1.03 kB
import React from 'react'; import PropTypes from 'prop-types'; class SelectOption extends React.Component { constructor(props) { super(props); this.onClickHandler = this.onClickHandler.bind(this); } onClickHandler(event) { event.preventDefault(); event.stopPropagation(); this.props.onSelect(this.props.option, event); } render() { return ( <div className={`select-option ${this.props.className}`} role="button" onClick={this.onClickHandler} > <span className="select-option-label"> {this.props.children} </span> </div> ); } } export default SelectOption; SelectOption.propTypes = { onSelect: PropTypes.func, option: PropTypes.string, className: PropTypes.string, children: PropTypes.node.isRequired }; SelectOption.defaultProps = { onSelect: f => f, option: '', className: '' };