React native source not compiling correctly when using mocha + babel - react-native

Im having a bit of an issue after upgrading to React Native 0.30. Using mocha, and babel I transpile the react native source before test run. I'm now seeing issues where modules cannot be found.
Here's an example:
Error: Cannot find module 'AssetRegistry'
The corresponding file can be found here https://github.com/facebook/react-native/blob/master/Libraries/Image/AssetSourceResolver.js#L21. It looks as if babel cannot locate the AssetRegistry file that is local in this directory.

Ok so it turns out that react-native-maps was calling an internal react-native library. react-native-mock has most of the internals mocked for react native however the internal library for the Image utility was not mocked.
I just used mockery to mock the library and all seems to work now.

Related

React Native Init Command Generating Typescript Project

It feels like a basic question but whenever I am trying to create a react native project using the command provided here It is always creating a typescript project for me instead of blank javascript project. How do I force it to create a blank javascript project what I am doing wrong?
Here is screenshot of App.js of the project that is being created
I have also tried making a project using native-base blank template but it is throwing an error
npx react-native init MyApp --template #native-base/react-native-template
React Native defaults new applications to TypeScript, but JavaScript may still be used. Files with a .jsx extension are treated as JavaScript instead of TypeScript, and will not be typechecked. JavaScript modules may still be imported by TypeScript modules, along with the reverse.
https://reactnative.dev/docs/typescript#using-javascript-instead-of-typescript

React native metro config for multi-package workspace

I'm trying to create an example React Native application for my package (https://github.com/BenJeau/react-native-draw) which now is divided in multiple npm packages. Everything is working with Expo, but since I am introducing non-Expo compatible packages, I need to switch the example to a pure React Native project (which can be found in the feat-skia branch).
I inspired myself from #react-navigation repository layout and it worked for the Expo example, but now that I'm moving to a pure React Native example, it is not working either giving one of the following errors variations when loading components from the packages within my library:
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
Invariant Violation: View config getter callback for component 'RNSVGPath' must be a function (received 'undefined').
Would anyone know how to properly configure metro or have links on setting up metro in a workspace in a pure React Native project?
Thanks!

React native and webassembly issues

We wrote an algorithm using rust and we compiled the code to web assembly
we want to integrate those functions into a react native app,
so i took the compiled folder that contain .wasm it shows.
Error: Unable to resolve module ./fn_op.wasm from
assets/libs/ofs_wasm/index.js
How can i resolve this issue with react native and how to integrate .wasm files into it
is there a configuration that i can override same as the case with react-cli for webpack

react native how to know if a repo I am importing is a native module

my question might be a little bit silly or ambiguous since I am fairly new to react native.
I'm trying to use the following repository for my react-native project https://github.com/smekalka/react-native-universal-pedometer. I have noticed that the repo is implemented in .java with platform folder unlike the regular .js or .ts files I used to see. Is this repository considered native module as react native doc describe?
Or in general how I can tell the whatever lib I am using is a native module.
The project is previously tested are under the support of expo-cli. I experienced the error null is not n object while using this repo. If so, I am probably going to eject the expo-cli and rewrite my code so I can use and even create own native-module for full control, some core implementations that written in other languages or expo-cli does not support.
Yes, the android and ios directories in the repository contain the 'native' code used to implement the platform-specific hooks that the Javascript will be able to pick up. Expo is not able to use these native modules or native code so your assumption is correct; you will need to eject your app in order to use this module.
If your app is below version 0.60 of React Native, after installing the module you will need to run react-native link react-native-universal-pedometer to link the native code to the Javascript runtime. If you're above 0.60, it will link automatically when installed.

Cannot find module for pre-built browserify package in react-native

I am building an application using react native and the code depends on a third party library which only offers pre-built browserify bundle.
It works fine in the browser, but when I am using it in react native, it is throwing error as cannot find module .
I think it might be some piece of code which cannot work in react native but can work in browser but with the error I cannot figure it out.
Is there a solution for this.
Thanks.