JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 251
  • Score
    100M100P100Q87649F
  • License MIT

Alert popup for ReactJS

Package Exports

  • react-popup-alert

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-popup-alert) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

react-popup-alert

NPM JavaScript Style Guide

Install

npm install --save react-popup-alert

Usage

import React from 'react'

import Alert from 'react-popup-alert'
import 'react-popup-alert/dist/index.css'

const App = () => {
  const [alert, setAlert] = React.useState({
    type: 'error',
    text: 'This is a alert message',
    show: false
  })

  function onCloseModal() {
    setAlert({
      type: '',
      text: '',
      show: false
    })
  }

  function onShowModal(type) {
    setAlert({
      type: type,
      text: 'Demo modal',
      show: true
    })
  }

  return (
    <div>
      <div style={{ margin: 'auto', marginTop: 50 }}>
        <button onClick={() => onCloseModal()}>Hide modal</button>
        <button onClick={() => onShowModal('success')}>
          Show success modal
        </button>
        <button onClick={() => onShowModal('error')}>Show error modal</button>
        <button onClick={() => onShowModal('warning')}>
          Show warning modal
        </button>
      </div>
      <Alert
        header={'Header'}
        btnText={'Close'}
        text={alert.texxt}
        type={alert.type}
        show={alert.show}
        onClosePress={onCloseModal}
        pressCloseOnOutsideClick={true}
        showBorderBottom={true}
        modalStyles={{}}
        headerStyles={{}}
        textStyles={{}}
        buttonStyles={{}}
      />
    </div>
  )
}

export default App

License

MIT © jakobinn