此错误与使用react-native-maps无关,因为有一些解决方案可用。 我正在使用 Expo 和 React Native 开发一个简单的应用程序,但收到此错误。
感谢任何人都可以在这里提供的帮助!
我的package.json是
"dependencies": {
"@expo/metro-runtime": "~3.2.3",
"@react-native-async-storage/async-storage": "1.23.1",
"@react-navigation/native": "^6.1.18",
"@react-navigation/native-stack": "^6.11.0",
"axios": "^1.7.7",
"expo": "~51.0.28",
"expo-clipboard": "~6.0.3",
"expo-crypto": "~13.0.2",
"expo-device": "~6.0.2",
"expo-font": "~12.0.10",
"expo-image": "~1.12.15",
"expo-localization": "~15.0.3",
"expo-status-bar": "~1.12.1",
"expo-system-ui": "~3.0.7",
"firebase": "^10.13.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.74.5",
"react-native-dotenv": "^3.4.11",
"react-native-pager-view": "6.3.0",
"react-native-safe-area-context": "4.10.5",
"react-native-screens": "3.31.1",
"react-native-svg": "15.2.0",
"react-native-web": "~0.19.10"
},
从“react-native-pager-view”导入PagerView;
这导致了错误,此时 Web 上不支持 Expo PagerView,即使没有提及原因,也会导致完整的 Web 构建停止。
只需删除它,它将再次构建网络构建。
如果你想用的话
const [PagerView, setPagerView] = useState(null);
// Loading this way because PagerView is not available on the web
useEffect(() => {
const loadPagerView = async () => {
if (!isPlatformWeb) {
console.log("I am not on web");
const PagerViewModule = await import("react-native-pager-view");
setPagerView(() => PagerViewModule.default);
} else {
console.log("I am on web");
}
};
loadPagerView();
}, []);
然后使用它。