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 install api-modal-for-react
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>
);
};
| 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.: '/' |
MIT © Anoerak