How ebay/nice-modal-react works
NiceModal is a small React utility for globally managing modal visibility, arguments, registration, and completion. A caller shows a modal by component or ID; shared state drives a provider placeholder, which renders registered modal wrappers only when needed. Modal components use the hook to hide, remove, or resolve promise-based interactions, while adapter helpers map state to UI-library dialog props. The runtime is concentrated in one source file, so distinct responsibilities share that path; relationships and capabilities are documented or visible in its excerpt.
Main entry points: index.tsx Show / Hide API
Components 13
Modal API
- Show / Hide API
src/index.tsx - Promise Results
src/index.tsx - useModal Hook
src/index.tsx
State and Rendering
- Modal Registry
src/index.tsx - Context Provider
src/index.tsx - Modal Reducer
src/index.tsx - Modal State
src/index.tsx - Modal Placeholder
src/index.tsx - Created Modal Wrapper
src/index.tsx
UI Adapters
- Ant Design Adapters
src/index.tsx - Material UI Adapter
src/index.tsx
Other components
- Application Caller
- UI Dialog Component
Connections 17
- Application Caller → Show / Hide API: calls show
README.md - Show / Hide API → Modal State: dispatches updates
src/index.tsx - Show / Hide API → Promise Results: creates promises
src/index.tsx - Context Provider → Modal State: provides context
src/index.tsx - Context Provider → Modal Placeholder: renders
src/index.tsx - Modal Placeholder → Modal Registry: looks up modals
src/index.tsx - Modal Placeholder → Created Modal Wrapper: renders registered
src/index.tsx - Created Modal Wrapper → useModal Hook: supplies modal ID
src/index.tsx - useModal Hook → Show / Hide API: calls show / hide
src/index.tsx - Show / Hide API → Modal Reducer: dispatches actions
src/index.tsx - Modal Reducer → Modal State: updates state
src/index.tsx - UI Dialog Component → useModal Hook: uses hook
README.md - UI Dialog Component → useModal Hook: hides or resolves
README.md - Ant Design Adapters → UI Dialog Component: maps dialog props
src/index.tsx - Material UI Adapter → UI Dialog Component: maps dialog props
src/index.tsx - Promise Results → Application Caller: returns promise
README.md - Modal Registry → Modal Placeholder: registers components
src/index.tsx