What are the steps to publish a react native library with native codes (Java and Objective C) - react-native

I want to publish a react native library to npm with native codes (Java and Objective C). I have created a react native app and the native modules and native UI components are working fine in the app but I don't know how to publish my code as a react native library.

If you have completed all the tests, you can do this with a simple library.
that is create-react-native-library
This is shown in the official document of react-native.
You can also use create-react-native-module, a library with multiple added functions based on react-native-create-library

Related

Can native react app code convert/rollback to native mobile code(ios and android)?

Basically the title says all - Can native react app code convert/rollback to native mobile code(ios and android)?
Background - there is a react native app and there are some bugs and I would like to export the react native code to their native app code (ios and android) which I can fix them in native apps.
No. The React Native JavaScript is never translated into Swift or Java code and then compiled - it runs within the Safari or Chrome JavaScript engines. See here for more details.
However, as its name implies, React Native does rely on native code for more complex operations. If the bugs are in those npm modules you might be able to fix them there.

How to detect if my library is running with React Native

I have a native library that can be used by react native app or traditional native app. Inside of my library, I want to check if this native library is running in react native environment or not.
Any one has suggestion?

Swagger codegen for React Native

I'm a fresher with Javascript and React Native.
My current project is a cross-platform app (PC, Web, Android and IOS) so they use Swagger to create API and document.
I'm using React Native to develop mobile version of this project but I dont know how to generate React Native code from Swagger and use it in my project.
Any help? Thanks!
I created a tool so that you can use it.
https://github.com/hosseinmd/swagger-typescript.
This module will generate a services.ts/js for you to include all APIs of swagger. Swagger-typescript using axios internally

React Native using Expo SDK is really native ?! or like cordova

I am new to React Native and I know that there are two ways to develop native applications using react native
1- react native init --> need to compile the native cod
==> Result is Native Application for Android "Android SDK required" and Native Application for IOS "Xcode required"
2- create react native app --> no need to compile the native code !!
as CRNA uses Expo_SDK to access native API, but :
Is the result app is really native! or Expo Sdk is like Cordova but used by React and if result native, Expo claims that the result is native!, have they cloned both Android Sdk and Xcode for IOS or how does it work ?!
Expo apps are React Native apps which contain the Expo SDK. The SDK is a native-and-JS library which provides access to the device’s system functionality (things like the camera, contacts, local storage, and other hardware). That means you don’t need to use Xcode or Android Studio, or write any native code, and it also makes your pure-JS project very portable because it can run in any native environment containing the Expo SDK.
Expo also provides UI components to handle a variety of use-cases that almost all apps will cover but are not baked into React Native core, e.g. icons, blur views, and more.
Finally, the Expo SDK provides access to services which typically are a pain to manage but are required by almost every app. Most popular among these: Expo can manage your Assets for you, it can take care of Push Notifications for you, and it can build native binaries which are ready to deploy to the app store.
You should take a look at the Expo doc
Expo app is as native as React native. They do the following things so you don't need to setup Android / iOS SDK locally.
provide Expo App on Android/iOS
so you can build the js code and use Expo App to debug during the development.
provide build server
once you run expo build command, expo will upload the compiled js code and build Android/iOS file on their server. You can download the built file from their server.
You can eject from the Expo, setup Android / iOS SDK locally, and build the app as normal React Native app
Expo (and react-native) apps use native (android and ios) ui components to render the apps ui, like any native android or ios app would. Therefore they can be considered as native apps.
However your app logic is executed within a javascript thread an will communicate with the native threads (through the react-native bridge) to modify the native ui components. Since the bridge is completely asynchronous this should not affect the native ui performance of your application. If you want to understand the communication between js and native code it may be a good start to read this guide.
2- create react native app --> no need to compile the native code !!
With expo there is no need to compile native code, as expo already includes a "ready to use build" of react-native along with several other common react-native libraries. In an expo app this will be used together with your javascript bundle which than communicates through the react-native bridge with the already present native part.
They are basically just abusing the fact that you can inject different javascript bundles into a prebuilt react-native app. (as long as you are using only accessing a subset of the native functionality of that prebuilt app)
Note that Appcenters codepush uses the same functionality and their setup integration actually delivers a nice example how different javascript bundles can be loaded without touching the native part:
in ios AppDelegate.m this line is changed:
original react-native js-bundle loading which always resolves a static bundle
return [[NSBundle mainBundle] URLForResource:#"main" withExtension:#"jsbundle"];
js-bundle loading with codepush which can resolve to different js-bunldes
return [CodePush bundleURL];
Link to full codepush ios integration guide

Expo: Can we use node modules like mqtt.js?

If Expo (create-react-native-app) is pure JavaScript, can I use other node modules in my Expo app?
in Expo, you can use any client based Javascript module, that you find in npm or that you created yourself.
But you can't use any kind of modules that has native parts in it. (Packages that you need to link to your react native projects can't be used) Although, Expo has its own SDK for your native needs.
The package you are talking about (mqtt.js) is a nodejs module, which can't be used with react native or in your case with Expo.
Just a guess, if you are trying to have a browser in your react native or Expo project, react native has a builtin in-app browser you might want to check out; https://facebook.github.io/react-native/docs/webview.html