React native app to react native web problem (typescript, babel) - react-native

Hello so I'm working on an app for android and iOS which is quite developed by now and I'd like to activate react-native-web on it. the problem is that I have a bug when I try to run the script to launch the web development server :
The first error at the top is the one I'm struggling with I've tried updating my babel config :
I tried deleting the babel config at the root of my project and it changed nothing like the babel config has no importance
It is being used though to build the android app i know that, but for the react native web build it seems he has no importance
But is still get the same error again and again
please let me know if you need any more information's on this issue

Related

React-Native, React-Native-Web and React-Navigation/Stack

Has anyone been able to get React-Native 0.7, React-Native-Web and React-Navigation/Stack 6.2.3 to work on web? I have a small app working on iOS and Android which I am trying to enable on web too. iOS and Android portion work fine and using metro.
However, webpack build continues to error out with "Module parse failed: Unexpected token" on the NavigationContainer.
I tried searching both react-native-web and react-navigation Issues on their respective GitHub Repositories. However, could not find something to solve my issue. Also tried modifying webpack.config with several different configurations/loaders.
Used links below as a reference too:
https://arry.medium.com/how-to-add-react-native-web-to-an-existing-react-native-project-eb98c952c12f
https://gist.github.com/skabbes/0bfa0a969aac8ec13f716dda1ad2ab43
Yes, it happens that I maintain a library that does just that: creates a bare React Native app that also runs on the web: 🌒 Luna - https://github.com/criszz77/luna
Here is the live example: https://criszz77.github.io/luna/
You can find more on the wiki page about how it's implemented and you can also implement it by yourself: https://github.com/criszz77/luna/wiki
By using react-scripts, you don't have to handle webpack, babel and other hard configs by yourself.
It currently doesn't run on 0.7 (didn't have time to make the update), but it's in plan to support all the latest versions of course ASAP.
EDIT: Updated to 0.70.3 🎉

React-Navigation and installation error and first-usage

I am new to react-native or you can say new to React and I am working on react-native navigation I have installed all the required libraries as instructed in https://reactnavigation.org/docs/getting-started but when I am running my code it is giving an error as '#react-navigation/native could not be found within the project or in this directories.' What should I do is there any way to get started with my code? Help me
If you have installed your app following the react native cli guide you might want to try running
gradle clean
in your android folder und then try to run your app in the emulator again.
On my first steps with react native I stumpled upon the same issue. :-)

how can I change web application without changing the app with expo

I have an expo react native project which works perfectly fine on every android device that I have tried.
but when I tried to build a pwa version of the project with expo build:web , the components renders in a totally wrong position and the output is not acceptable at all.
I want to know if anyone has the same problem with expo web builds, and how you manage to fix this problem.
is there any way that I change the implementation of the web application without changing the output of android app?
thank you all.
Did you try to use Platform Specific Code with https://reactnative.dev/docs/platform-specific-code
With your situation, it will be something like this
HeaderBar.js # Webpack, Rollup or any other Web bundler
HeaderBar.native.js # React Native bundler for both Android and iOS (Metro)
HeaderBar.android.js # Android only

How to run a react native app (a bare workflow from expo or a regular one) in web (browser)?

I'm trying to run my React Native app as a web site, on a browser.
I tried to go according to https://necolas.github.io/react-native-web/docs/installation/ but the instructions on the Setup page are not clear.
I found some (rare) posts regarding this, but they are old (2019) and seem to deviate from the info in the link above.
I use yarn android to run it on android.
So, I tried using yarn web. Didn't work.
Also, tried the basic react-native start followed by react-native run-web.
It seems the run-web command is not what is needed.
Any assist appreciated.
P.S. I initialized my project through Expo, as a Bare Workflow project. Hope that helps
According to the docs:
Expo for web can work on any React Native project. When you initialize a new project with a bare workflow template using expo-cli, if you run yarn web or npm run web it will start up expo-cli and open your project in a web browser.
The same guides for web from the managed workflow apply here.
So basically just initialise your project using expo init project-name and then select bare workflow or managed workflow. After that you can execute npm run web. It will open up the browser and run the web version of it. Keep in mind that there are some incompatibility of libraries from expo, for example, the Webview is incompatible on the web so you need to switch when on web to an iframe or so.

What is the Difference between running react native code on Web Browser and Expo GO?

I am running React Native Code on the Web browser and in Expo Go. In the web browser, it runs fine without any error but in Expo Go, it is not importing even a single module and showing module not found error again and again on almost all modules even after reinstalling them and also reinstalling node_modules.
Can anyone tell what's the difference between running react-native code on Expo Go and Web Browser?
Also what is this issue and how to solve it?