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

bootbox-react

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bootbox-react

bootboxjs wrapped for React <http://bootboxjs.com>

latest
npmnpm
Version
1.1.1
Version published
Maintainers
1
Created
Source

Bootbox React

bootbox-react is a wrapper of the bootboxjs <http://bootboxjs.com> module for React. Fancy alerts, confirm and prompt dialogs built on top of Bootstrap. Check the website for more information.

How To Install

  • Install: npm i --save bootbox-react

How to Use

import  React, {useState} from  'react';
import  Bootbox  from  'bootbox-react';
...
function  App() {
	const [showConfirm, setShowConfirm] = useState(false);
	const [showAlert, setShowAlert] = useState(false)
	const [showPrompt, setShowPrompt] = useState(false)
	
	const handleConfirm = () => {
		console.log("You clicked Yes!");
		return setShowConfirm(false);
	}
	
	const handleCancel = () => {
		console.log("You clicked No!");
		return setShowConfirm(false);
	}

	const handleClose = () => {
		console.log("You closed Alert!");
		return setShowAlert(false);
	}

	const handlePrompt = (result) => {
		console.log(`User input: ${result}`);
		return setShowPrompt(false);
	}

	return(
		<>
			<button onClick={ () => setShowConfirm(true) } Confirm </button>
			<Bootbox show={showConfirm} 
				type={"confirm"}  
				message={"Do That?"}  
				onSuccess={handleYes}  
				onCancel={handleNo}  
				onClose={handleNo} 
			/>

			<button onClick={ () => setShowAlert(true) } Alert </button>
			<Bootbox show={showAlert} 
				type={"alert"}  
				message={"This is a simple alert"}  
				onClose={handleClose} 
			/>

			<button onClick={ () => setShowPrompt(true) } Prompt </button>
			<Bootbox show={showPrompt} 
				type={"prompt"}  
				message={"What's your name"}  
				onPrompt={handlePrompt} 
			/>
		</>
	)
}

export default App
	

Props

NameshowtypemessageonSuccessonCancelonCloseonPromptcancelClassNamessuccessClassNamescancelLabelsuccessLabel
PropTypeboolstringstringfunctionfunctionfunctionfunctionstringstringstringstring
Is Requiredrequiredrequiredrequiredrequired for 'confirm'required for 'confirm'required for 'alert', optional for othersrequired for 'prompt'optionaloptionaloptionaloptional
Accepted Valuestrue, false"alert", "confirm", "prompt""Your message"callback function to handle Yescallback function to handle Nocallback function to call when box is closedcallback function to handle user's inputclassname(s) to apply to "No" button"classname(s) to apply to "Yes" button"Custom label to apply to "No" buttonCustom label to apply to "Yes" button
Defaultfalsenull""nullnullnullnull"btn-danger""btn-primary""No""Yes"

Keywords

bootstrap

FAQs

Package last updated on 18 Apr 2020

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