react-ts-modal-cserizay
TypeScript icon, indicating that this package has built-in type declarations

1.3.0 • Public • Published

react-ts-modal-cserizay - Modal creation & management in React (compatible with TypeScript)

React TypeScript

Author

Table of Contents

Installation

npm install react-ts-modal-cserizay

Prerequisites

Usages

import { useState } from 'react';
import { ModalWindow } from 'react-ts-modal-cserizay';

const RandomReactComponent = () => {
	// Create a state to manage the modal's state
	const [isOpen, setIsOpen] = useState(false);

	// Create a function to open the modal
	const handleOpen = () => {
		setIsOpen(true);
	};

	// Create a function to close the modal
	const handleClose = () => {
		setIsOpen(false);
	};

	return (
		<div>
			<button onClick={handleOpen}>Open Modal</button>

			<ModalWindow isOpen={isOpen} onClose={handleClose}>
				<p>You successfully opened the modal!</p>
			</ModalWindow>
		</div>
	);
};

&& another example

import { useState } from 'react';
import { ModalWindow } from 'react-ts-modal-cserizay';

const AnotherRandomReactComponent = () => {
	const [isOpen, setIsOpen] = useState(false);

	const handleClose = () => {
		setIsOpen(false);
	};

	return (
		<div>
			<ModalWindow isOpen={isOpen} onClose={handleClose}>
				<p>Are you sure you want to quit?</p>
				<button onClick={handleClose}>Yes, close the modal.</button>
			</ModalWindow>
		</div>
	);
};

License

MIT

This project was created by [Clément Serizay] for OpenClassrooms Project 14.

Package Sidebar

Install

npm i react-ts-modal-cserizay

Weekly Downloads

30

Version

1.3.0

License

MIT

Unpacked Size

15.5 kB

Total Files

17

Last publish

Collaborators

  • monkeycs60