react-popup-alert
v2.0.0
Published
Alert popup for ReactJS
Downloads
1,066
Maintainers
Readme
react-popup-alert
npm install --save react-popup-alert
Use example
Usage
import React from 'react'
import Alert from 'react-popup-alert'
const App = () => {
const [alert, setAlert] = React.useState({
type: 'error',
text: 'This is a alert message',
show: false
})
function onCloseAlert() {
setAlert({
type: '',
text: '',
show: false
})
}
function onShowAlert(type) {
setAlert({
type: type,
text: 'Demo alert',
show: true
})
}
return (
<div>
<div style={{ display: 'flex', justifyContent: 'center', marginTop: 50 }}>
<button onClick={() => onCloseAlert()}>Hide alert</button>
<button onClick={() => onShowAlert('success')}>
Show success alert
</button>
<button onClick={() => onShowAlert('error')}>Show error alert</button>
<button onClick={() => onShowAlert('warning')}>
Show warning alert
</button>
</div>
<Alert
header={'Header'}
btnText={'Close'}
text={alert.text}
type={alert.type}
show={alert.show}
onClosePress={onCloseAlert}
pressCloseOnOutsideClick={true}
showBorderBottom={true}
alertStyles={{}}
headerStyles={{}}
textStyles={{}}
buttonStyles={{}}
/>
</div>
)
}
export default App
Parameters
License
MIT © jakobinn