Sha256: b8c642335ab035476534dc4c19436575dd2df977c432b2dd468b817032048108
Contents?: true
Size: 1002 Bytes
Versions: 70
Compression:
Stored size: 1002 Bytes
Contents
import React, { Component } from 'react'; import PropTypes from 'prop-types'; import { FormControl } from 'patternfly-react'; class TypeAheadInput extends Component { constructor(props) { super(props); this.handleKeyPress = this.handleKeyPress.bind(this); } componentDidMount() { if (this.ref) { this.ref.addEventListener('keydown', this.handleKeyPress); } } componentWillUnmount() { if (this.ref) { this.ref.removeEventListener('keydown', this.handleKeyPress); } } handleKeyPress(e) { this.props.onKeyPress(e); } render() { return ( <FormControl inputRef={(ref) => { this.ref = ref; }} onFocus={this.props.onInputFocus} type="text" {...this.props.passedProps} /> ); } } TypeAheadInput.propTypes = { passedProps: PropTypes.shape({}).isRequired, onKeyPress: PropTypes.func.isRequired, onInputFocus: PropTypes.func.isRequired, }; export default TypeAheadInput;
Version data entries
70 entries across 70 versions & 1 rubygems