modal-react-native-web is a JavaScript library that provides a web-compatible implementation of the core `Modal` component from React Native. It aims to replicate the API, behavior, and design of the native React Native Modal for projects utilizing `react-native-web`. The current stable version is `0.2.0`, last updated in 2018. Due to its age and reliance on outdated peer dependencies (React 16.x.x, React Native Web 0.9.x), its release cadence has ceased, and it is largely considered unmaintained for modern React/React Native Web environments. While it offers a solution for older `react-native-web` setups, `react-native-web` itself now includes a native `Modal` component, rendering this package largely obsolete for new projects.
npm install modal-react-native-webVerified import paths — ran on the pinned version, not inferred.
This example demonstrates how to import and use the `Modal` component, controlling its visibility with local state and handling dismissal. It shows a basic modal with text and a button to hide it, triggered by another button on the main screen.
It is strongly recommended to use the native `Modal` component now available directly in `react-native-web` (since v0.13+). For projects requiring older `react-native-web` versions, ensure all peer dependencies are precisely matched. Consider migrating to a modern `react-native-web` version to utilize its built-in `Modal`.
Remove `modal-react-native-web` and use the `Modal` component directly from `react-native` (which `react-native-web` will resolve) or import `Modal` from `'react-native-web'` if explicitly needed for web-specific imports. Ensure your `react-native-web` version is sufficiently new (>=0.13.0).
Always consult the `react-native-web` documentation for its native `Modal` component for a complete and up-to-date list of supported props and behaviors. For this package, trial and error or source code review is necessary for unsupported props.
Upgrade to `modal-react-native-web@0.2.0` or later to mitigate these specific issues. However, given the package's overall status, a full migration to native `react-native-web` Modal is preferred.
This package is largely unmaintained and expects older React versions. The most robust fix is to remove `modal-react-native-web` and use the `Modal` component directly from a recent `react-native-web` version. If you must use this package, downgrade your `react`, `react-dom`, `react-art`, and `react-native-web` packages to their respective `16.x.x` and `0.9.x` versions.
For modern `react-native-web` (v0.13.0+), simply import `Modal` from `'react-native'`. If using an older `react-native-web` and still needing this package, ensure `modal-react-native-web` is installed and imported as a default export: `import Modal from 'modal-react-native-web';`.