Attempted import error: 'createElement' is not exported from 'react-native'. @react-native-picker/picker/js/Picker.web.js

1.9k Views Asked by At

Following error is being thrown while trying to use @react-native-picker/picker in a react-native-web application.

package.json dependencies include:

"@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

enter image description here

1

There are 1 best solutions below

0
On

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 !