1

尝试在 react-native-web 应用程序中使用 @react-native-picker/picker 时引发以下错误。

package.json 依赖项包括:

"@react-native-picker/picker": "^1.16.1",
"babel-plugin-react-native-web": "^0.17.0",
"customize-cra": "^1.0.0",
"react-app-rewired": "^2.1.8"
"react": "16.9.0",
"react-dom": "16.9.0",
"react-native-web": "^0.15.7"


I'm using react-native version 0.61.5

在此处输入图像描述

4

1 回答 1

1

Hi, This error costed me a hackathon win !

basically at picker.web.js , it's not able to import createElement. if you go and check picker.web.js file createElement is used something like this.

const createElement = ReactNativeWeb.createElement || ReactNativeWeb.unstable_createElement; 

we just need unstable_createElement ! so comment out this line and add following to the imports. !

import { unstable_createElement as createElement } from 'react-native-web'; 

now export your web builds !

于 2022-01-31T19:29:33.603 回答