Is there a recent Webpack HMR react-native boilerplate out there?
I am having trouble finding a best practice for integrating an existing setup with Webpack and HMR to be used with react-native and the react-native packager. The resources I found online on this topic are dated.
I know that it uses Facebook's watchman.
I also know of the webpack-watchman-plugin, but I don't think that will allow me to trigger a webpack build and serve the compiled assets to react-native. I know that watchman has -- trigger functionality, but don't think digging in the packager local CLI is the answer either.
I'm at a loss for finding decent documentation for Facebook's packager, and not sure where to get started on this. My goal is to take an existing boilerplate used for web React, and use the boilerplate setup for react-native. I understand about the rendering differences, this is mostly the build tool part.
I've resolved this issue by not trying to integrate webpack with react-native, but by not using webpack at all and using react-native's packager. Still working on it, but I like it so far! Using it for my Open-Source react-native boilerplate project, strangeluv-native
Related
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 🎉
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.
I'm trying to integrate the react library called react-canvas-draw with expo.
the error in question is:
Component Exception - View config getter callback for component 'canvas' must be a function (received 'undefined'). Make sure to start component names with a capital letter.
I think its a babel config fix. converting es2015 to es7 or something then to react native code. I have no idea.
So I stopped using react-expo because it's a pain in the ass to configure all the settings with (Babel, es6, jest, eslint, etc & metro configs). I Generally know what all those packages do in layman's terms but I do not know anything with setting them up together and what goes where.
Instead I'm using npx create-react-native-app It comes pre-configured for what I'm doing and it has some neat feature like hot-reloading so it's just as fast in development. It's not as helpful as expo with ease of use with ios and android setup and exports but I can manage the configurations on my own.
I am building an app using Create-React-Native-App. As such, my testing and development is in Expo. I am looking for a solution to help with i18n, mostly translations and RTL. I found that ex-react-native-i18n works great, until I try ejecting to create the App, because it needs expo. (Which I don't need or want in the production App)
with react-native-i18n I get this error:
react-native-i18n module is not correctly linked
I tried react-native link and yarn link without success. The ReadMe page for react-native-i18n has extensive instructions for manual linking, but only for AFTER ejecting.
What am I missing here?
Is there a better solution that I'm missing?
Thanks.
I don't think it will be possible to get that module working before ejecting.
Have you tried this library?
https://github.com/xcarpentier/ex-react-native-i18n
Mark
I created a project with create-react-native-app and I want to use jest-enzyme matchers, in their Readme there is a section on how to use it with create-react-app, but I did not find any info on how to use it with create-react-native-app.
To add these matchers all I need is to create a jest setup file, but create-react-native-app does not seen to allow for custom jest setup file.
So it's possible to a use a custom jest setup file without ejecting from create-react-native-app?
Also is there any way to add a jest setup file for create-react-native-app?
Maybe what you are looking for is http://airbnb.io/enzyme/docs/guides/react-native.html which explains as follows:
Unfortunately, React Native has many environmental dependencies that can be hard to simulate without a host device.
This can be difficult when you want your test suite to run with typical Continuous Integration servers such as Travis.
A pure JS mock of React Native exists and can solve this problem in the majority of use cases.
To install it, run:
npm i --save-dev react-native-mock
After adding that dependency you need to import the /mock within your tests you should good to go. Maybe I am out of context, you can update your problem and give us some extra context so we can craft a better answer.
Ultimately, there is something important to mention in this thread: https://github.com/airbnb/enzyme/issues/928 for the time of this post RN is in version 0.47 and working with react 16 alpha which is not a supported version for enzyme (the people at enzyme only work with rc versions) so if that is your case things looks quite difficult as there is no official support, however, last comment https://github.com/airbnb/enzyme/issues/928#issuecomment-324584942 offers unofficial alternatives
PD: make sure you follow the installation instructions here: http://airbnb.io/enzyme/docs/installation/index.html