Skip to content

Instantly share code, notes, and snippets.

@gisderdube
Created November 13, 2018 17:02
Show Gist options
  • Save gisderdube/c04d5bb50eeba1452c79ba2f564555da to your computer and use it in GitHub Desktop.
Save gisderdube/c04d5bb50eeba1452c79ba2f564555da to your computer and use it in GitHub Desktop.
import React, { Component } from 'react'
class GlobalError extends Component {
render() {
if (!this.props.error) return null
return (
<div
style={{
position: 'fixed',
top: 0,
left: '50%',
transform: 'translateX(-50%)',
padding: 10,
backgroundColor: '#ffcccc',
boxShadow: '0 3px 25px -10px rgba(0,0,0,0.5)',
display: 'flex',
alignItems: 'center',
}}
>
{this.props.error}
&nbsp;
<i
className="material-icons"
style={{ cursor: 'pointer' }}
onClick={this.props.resetError}
>
close
</i>
</div>
)
}
}
export default GlobalError
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment