Can't import react-native-web

It doesn’t appear that I can import from react-native-web in a Snack. Is that expected behavior? I was a bit surprised, given that there is the Web tab for previewing, which presumably is using react-native-web.

Thanks in advance.


Hey @thunkmark, what exactly do you mean by “import from rn-web”?


For example, if I have the following in a Snack I get an error:

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

The error I get in the Web preview tab is:

Unable to resolve module 'module://react-native-web.js'
  Evaluating module://react-native-web.js
  Evaluating module://App.js.js
  Loading module://App.js
Error: Unable to resolve module 'module://react-native-web.js'
    at Object.eval (module://react-native-web.js!transpiled:1:113)
    at eval (module://react-native-web.js!transpiled:2:4)
    at eval (module://react-native-web.js!transpiled:3:3)
    at eval (<anonymous>)
    at [snack internals]
    at Object.n ([snack internals]
    at e.evaluate ([snack internals]
    at He ([snack internals]
    at [snack internals]

I get the same error, with a similar stack trace, if I use the iOS or Android preview tabs.


1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.