Skip to content

Basic modal which use API res to display status & statusText

Notifications You must be signed in to change notification settings

Anoerak/api-modal-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

api-modal-for-react

A modal component for displaying API responses in React. This package is part of the OpenClassrooms' Front-End Developer path. It is not meant to be used outside of this context. Once the path is completed, and the project validated, this package won't be maintained.

NPM JavaScript Style Guide

Install

npm install api-modal-for-react

Usage

import Modal from 'api-modal-module';

const App = () => {

	// Variables for the Modal Node Package
	const [showModal, setShowModal] = useState({ display: 'none' });
	const [apiResponse, setApiResponse] = useState({ status: 418, statusText: "I'm a teapot", data: {} });
	const [redirectPath, setRedirectPath] = useState('/');


  return (
	<div>
		<Modal apiResponse={apiResponse} modal__display={showModal} />
			<div>Modal Content</div>
	  	</Modal>
	</div>
  );
};

Props

| Prop Name        | Type   | Description                                        |
| ---------------- | ------ | -------------------------------------------------- | ----------------------------------------------------------- |
| apiResponse      | object | The response from the API call.                    | e.g.: { status: 418, statusText: "I'm a teapot", data: {} } |
| modal\display    | object | The display property for the modal.                | e.g.: { display: 'flex'/'none' },                           |
| redirectPath     | string | The path to redirect to after the modal is closed. | e.g.: '/'                                                   |

License

MIT © Anoerak


About

Basic modal which use API res to display status & statusText

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published