File size: 496 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
/* eslint-disable no-invalid-this */
import React from 'react'
export const handleFocus = (Component, Span = 'span') =>
class Focus extends React.Component {
state = { focus: false }
handleFocus = () => this.setState({ focus: true })
handleBlur = () => this.setState({ focus: false })
render() {
return (
<Span onFocus={ this.handleFocus } onBlur={ this.handleBlur }>
<Component { ...this.props } { ...this.state } />
</Span>
)
}
}
|