Skip to content

Instantly share code, notes, and snippets.

@namelos
Created November 30, 2015 12:52
Show Gist options
  • Select an option

  • Save namelos/85ecb9d146de597d7253 to your computer and use it in GitHub Desktop.

Select an option

Save namelos/85ecb9d146de597d7253 to your computer and use it in GitHub Desktop.
export const error = ComposedComponent =>
class extends Component {
state = { display: 0 }
toggle = display =>
this.setState({ display })
reset = () =>
this.toggle(0)
err = message => {
this.toggle(message)
setTimeout(this.reset, 1000)
}
render = () => <div>
<ComposedComponent { ...this.props } err={ this.err } />
<div onClick={ this.reset } className="hint-box-wrapper"
style={{ display: this.state.display === 0 ? 'none' : 'block' }} >
<div className="hint-box">
<div className="hint-box-inner">
{ this.state.display }
</div>
</div>
</div>
</div>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment