Create a .aar file from my react-native project and use it in other project? - react-native

is it possible? does .aar contain the javascript code what i have written for screens and components? will i be able to impost specific component from .aar in my new project?
Tried couple of things like this text but not able to generate .aar

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

How can I bundle .proto files with a React Native app?

I am trying to build an app to communicate with embedded devices using Protocol Buffers with protobuf.js
I want to load the content of .proto files at runtime. The files are pulled from a shared repo and I want to have them bundled with the app at build time.
I know I can read files with RNFS from DocumentDirectoryPath, but how do I tell React Native to put them there when building the app? Or is there a better way to do this?
probably a duplicate of In React Native how do you bundle a text file and read it's value at runtime?.
if you put anything inside android/app/src/main/assets folder it will be in your final .apk file, and you can read it with
RNFS.readFileAssets
Also there are more customized libraries like This one

React native, are there shell commands lines for generate screens/navigation/... files ?

From Symfony or Drupal, I used to use the shell for generate templates empty files (pages, entity, ...)
I'm a new react native developer, its really useful to have a console for generate some projects files.
I make several google search but I find nothing..
Basically you can not do this for react native. What you can do is use an editor like WebStorm and add some codes snippets and custom live templates. There is a great tutorial here.

How include aar whitch has JNI so file in React Native project

I have wrote a project by React Native,now I need to reference a android SDK to implement some functions.
the android sdk is a aar file,and it contains JNI,now it reports couldn't find "libjniload.so", the "libjniload.so" is in the aar.
If you want to reference an Android SDK, you must add the files to your android project in your react native project. That means, you must add the dependencies to your build.gradle, and copy the files to you libs folder etc.. This is not any different than adding .aar files to an Android project. After this, you will need to implement a native module to call its functions from react-native. This is the general procedure, what exact step is causing error?

What is the best folder structure to build two twin apps with React Native?

I need to create two twin apps with React Native and both apps will be 90% the same they will use some shared components and the styles will be different.
the question is : should i create one react native project and from there to building two apps
and the folder structure will be :
ReactProject
shared
project1
components
project2
components
index.ios.js
index.android.js
and when I want to build one of the apps I will need to change the main component.
or should I create to different React Native projects
and the folder structure will be :
shared
ReactProject1
components
index.ios.js
index.android.js
ReactProject2
components
index.ios.js
index.android.js
I would like to know what is the right approach to do this kind of project
thanks !
This is absolutely a personal preference as stated in comments. One could easily increase the number of structure options beyond 2. Other than that I can share my experience on this.
We build an app, actually 4 (quadruplets), from a single react native project. We choose that way because our apps had to be highly similar. They share same functionality. Furthermore, when one has more than one of these apps installed on their device they can easily switch between apps via deep linking. However they differ on the theme colors, logos, names and backend services to call etc. One of the ways to create multiple apps from a single project is to rename the project. But you can still produce multiple apps while keeping the project name same. Then you need to change some project files accordingly. These files are, for iOS;
Info.plist
project.pbxproj
AppDelegate.m
For Android;
strings.xml
MainActivity.java
MainApplicatoin.java
AndroidManifest.xml
android/build.gradle
app/build.gradle
Actually changing all these files manually is an error-prone and cumbersome action. So that in order to manage these changes we wrote a bash script that converts a base app to the version that we want. Using this approach we can manage 8 apps (quadruplets for iOS and Android) from a single project repo. In the end we are really happy about using React Native which let us build 8 production quality native apps in 3 months without knowing native app development at production level.