New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

react-dumb-modal

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-dumb-modal

A simpler react modal.

latest
Source
npmnpm
Version
1.2.0
Version published
Maintainers
1
Created
Source

React Dumb Modal

A simpler modal. A modal that is not self-aware.

var Modal = require('react-dumb-modal')
<Modal dismiss={function(){/* handle the dismiss here */}} />

Dumb Modals are always visible, hence being "dumb". Consequently you will need to control the visibility of the modal from the parent component. By moving all of the state out of the child component, it becomes easier to reason with. The same goes for any modal animations.

note: the dismiss prop is a function that will be called when a user presses escape or clicks off of the modal. Assuming you want to allow the user to dismiss the modal, you should implement some logic here that toggle off the modal (either by removing it altogether or changing the style).

Usage

See props in the usage example below:

<Modal
  dismiss={function(){}}
  overlayStyle={{background: 'rgba(0,0,0,.5)'}}
  overlayClassName='overlay' //if you prefer to use css styling set a className here
  modalStyle={{background: 'white'}}
  modalClassName='modal' //className for the actual modal box
  unstyled={true} //if true no default styles will be included
  />

Practical Example

import React, { Component } from 'react'
import Modal from 'react-dumb-modal'

class Page extends Component {
  toggleModal = () => {
    this.setState({showModal: !this.state.showModal})
  }

  render() {
    return(
      <div>
        {this.state.showModal ? <Modal dismiss={this.toggleModal} /> : null}
      </div>
    )
})

Keywords

react

FAQs

Package last updated on 03 Oct 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts