question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

react-native-web compatibility broke in 9.8.6

See original GitHub issue

Bug

Apologies if this turns out to be just me using it wrong, my project setup grew quite complicated over time…

I’m using react-native-svg in a project with react-native and react-native-web. When upgrading from 9.8.5 to 9.8.6 (or later) the web build starts breaking with the following error:


./node_modules/react-native-svg/lib/module/elements/Image.js
Attempted import error: 'requireNativeComponent' is not exported from 'react-native'.

It seems to me like the web compatibility layer is not used anymore, since it should not be loading that file for web at all. I tried looking at the diff for these versions but it’s quite large and all I can tell ist that the relevant files index.js and index.web.js were moved and renamed to .ts. I have WebpackResolve extensions set up like this: '.web.tsx', '.web.ts', '.web.js', '.ts','.tsx', '.js', which should still cover the changed extension from my point of view.

Environment info

React native info output:

info Fetching system and libraries information...
System:
    OS: Windows 10
    CPU: (8) x64 Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz
    Memory: 7.54 GB / 23.89 GB
  Binaries:
    Node: 10.16.0 - C:\Program Files\nodejs\node.EXE
    npm: 6.10.2 - C:\Program Files\nodejs\npm.CMD
  IDEs:
    Android Studio: Version  3.2.0.0 AI-181.5540.7.32.5056338

Library version: 9.8.6, also applies for 9.9.3

Versions of other packages:

react@16.8.6
react-native@0.60.5
react-native-web@0.11.7

Steps To Reproduce

Sorry I can’t provide more detailed steps right now. If you can point me to the currently recommended way of setting up a project that builds for native and web from the same codebase I can attempt to reproduce the issue with a fresh project.

Any hints towards what might be the problem for me are highly appreciated.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:12

github_iconTop GitHub Comments

2reactions
adrian1388commented, Sep 20, 2019

Sorry @OKNoah , my bad. Just this:

(Project Root)/config-overrides.js

module.exports = function override(config, env) {
  config.resolve.alias["react-native-svg"] = "react-native-svg-web";
  return config;
};
1reaction
OKNoahcommented, Sep 20, 2019

I fixed it changing from react-scripts to react-app-rewired and doing some changes in config-overrides.js

Share the changes.

Read more comments on GitHub >

github_iconTop Results From Across the Web

react-native-web compatibility broke in 9.8.6 #1106 - GitHub
I'm using react-native-svg in a project with react-native and react-native-web. When upgrading from 9.8.5 to 9.8.6 (or later) the web build ...
Read more >
react-native-web - npm
"React Native for Web" makes it possible to run React Native components and APIs on the web using React DOM. Documentation. The documentation ......
Read more >
Troubleshooting - React Native
You will also need to update your applications to load the JavaScript bundle from the new port. If running on device from Xcode,...
Read more >
React Native for Web
React Native Components and APIs on the Web ; Accessible HTML. Support different devices and input modes, render semantic tags. ; High-quality interactions....
Read more >
How to add React Native Web to an existing ... - Aryan Goharzad
This post covers the most customizable method of adding web support to a plain React Native app using webpack and react-native-web .
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found