skip to Main Content

i’m learning React Native.
I’m trying to use SafeAreaProvider and SafeAreaView but when i do this :

import { SafeAreaProvider, SafeAreaView } from "react-native-safe-area-context";

i got the message Cannot find module ‘react-native-safe-area-context’

Here are my versions :

"dependencies": {
    "@react-native-community/masked-view": "^0.1.11",
    "expo": "~48.0.18",
    "expo-status-bar": "~1.4.4",
    "react": "18.2.0",
    "react-native": "0.71.8",
    "react-native-safe-area-context": "4.5.0",
    "react-navigation": "^4.4.4"

Can you help me ? thank you a lot !

I tried to downgrade react-native-safe-area-context to 4.5 from 4.7.1

2

Answers


  1. You’re getting the error message "Cannot find module ‘react-native-safe-area-context’" because the SafeAreaContext library is not installed in your environment.

    The library is included in Expo Go, but if you’re using NPM, you should follow the instructions here.

    Run this command in your environment terminal to install the library locally:

    - npx expo install react-native-safe-area-context
    

    If that command doesn’t work, try this one instead:

    npx expo install react-native-screens react-native-safe-area-context
    
    Login or Signup to reply.
  2. restart the metro, close all terminal for this case

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search