This error was resolved for me when I followed the following steps:
npm install react-native-safe-area-context
Then rebuild the app: for ios:
cd ios
pod install
cd ..
npx react-native run-ios
Restart Metro clearing the cache:
npx react-native start --reset-cache