schiehll / react-alert

alerts for React
MIT License
608 stars 98 forks source link

Close #170

Closed faeztgh closed 3 years ago

faeztgh commented 3 years ago

Still not clear how to close alert in custom templates!

liorp commented 3 years ago

There's an onClose prop

dmikester1 commented 3 years ago

This is taken from the example on the home page for this library.

const AlertTemplate = ({ style, options, message, close }) => (
  <div style={style}>
    {options.type === 'info' && '!'}
    {options.type === 'success' && ':)'}
    {options.type === 'error' && ':('}
    {message}
    <button onClick={close}>X</button>
  </div>
)