![Create React App Officially Deprecated Amid React 19 Compatibility Issues](https://cdn.sanity.io/images/cgdhsj6q/production/04fa08cf844d798abc0e1a6391c129363cc7e2ab-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Create React App Officially Deprecated Amid React 19 Compatibility Issues
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
react-best-modal
Advanced tools
Simple is best. Accessible out of the box, tiny api, bring your own styles.
Simple is best. Accessible out of the box, tiny api, bring your own styles. Don't let libraries you use get in the way of what you want, build up, not down. React 16+ only.
npm install react-focus-lock react-best-modal --save
import React from 'react';
import BestModal from 'react-best-modal';
import { render } from 'react-dom';
const appRoot = document.getElementById('root');
const App = ({ showModal, closeModal }) => (
<div>
Hi Mom!
{showModal && (
<BestModal onRequestClose={closeModal} appRoot={appRoot}>
<button>Hello, World!</button>
</BestModal>
)}
</div>
);
render(<App />, appRoot);
NOTE: Make sure you have an element inside your modal that is focusable. Essentially, any input, button, or element with tabIndex="0"
. This is to ensure focus is set correctly inside the modal - while this isn't enforced, it's strongly advised.
It's up to you to style and position your modal. Want to disable scrolling content behind your modal? You have to do it yourself. There's an example implementation here.
react-best-modal
works perfectly with ReactTransitionGroup
.
If you're driving home for the ultimate accessible modal, make sure to use aria-labelledby
and aria-describedby
, for title and description of the modal, like so:
<BestModal
onRequestClose={closeModal}
appRoot={appRoot}
aria-labelledby="modal-title"
aria-describedby="modal-description"
>
<button onClick={closeModal}>close</button>
<h2 id="modal-title">Hello, World!</h2>
<p id="modal-description">This is a modal, hello worlding!</p>
</BestModal>
aria-labelledby
and aria-describedby
.This isn't supported. It's also bad practice to show many modals at a time.
BestModal
import BestModal from 'react-best-modal';
prop | type | required | description |
---|---|---|---|
children | ReactNode | yes | Your modal markup. |
onRequestClose | (e: KeyboardEvent) => void | yes | Callback when the modal wants to close. Up to you to action it. |
appRoot | HTMLElement | yes | Root of your application. The modal will add and remove accessible attributes when appropriate. |
className | string | no | |
disableFocusLock | boolean | no | Disables focus lock. Useful if something else wants to trap focus. |
All other props that are valid on a HTMLElement
are passed through.
FAQs
Simple is best. Accessible out of the box, tiny api, bring your own styles.
We found that react-best-modal demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.