Research
Security News
Threat Actor Exposes Playbook for Exploiting npm to Build Blockchain-Powered Botnets
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
react-native
Advanced tools
React Native is an open-source mobile application framework created by Facebook. It is used to develop applications for Android, iOS, Web, and UWP by enabling developers to use React along with native platform capabilities. It allows for the development of mobile apps using JavaScript and React, offering a rich mobile UI library and tools to deliver a native app experience.
UI Components
React Native provides a set of built-in core components like View, Text, and Image that you can use to build your app's UI. These components are pre-styled and ready to use, making it easy to develop complex UIs.
import { View, Text } from 'react-native';
function HelloWorldApp() {
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<Text>Hello, world!</Text>
</View>
);
}
Native Modules
Native Modules allow you to write modules in native code that can be called from JavaScript. This is useful for accessing platform-specific functionality that is not covered by the built-in React Native components.
import { NativeModules } from 'react-native';
const { CalendarModule } = NativeModules;
CalendarModule.createCalendarEvent('testName', 'testLocation');
Navigation
Navigation is essential for mobile apps. React Native can integrate with libraries like React Navigation to provide a way to navigate between screens.
import { NavigationContainer } from '@react-navigation/native';
import { createStackNavigator } from '@react-navigation/stack';
const Stack = createStackNavigator();
function App() {
return (
<NavigationContainer>
<Stack.Navigator initialRouteName='Home'>
<Stack.Screen name='Home' component={HomeScreen} />
<Stack.Screen name='Profile' component={ProfileScreen} />
</Stack.Navigator>
</NavigationContainer>
);
}
Flutter is Google's UI toolkit for crafting beautiful, natively compiled applications for mobile, web, and desktop from a single codebase. It is similar to React Native but uses Dart instead of JavaScript. Flutter provides its own widgets, which are drawn by the framework's own graphics engine.
Ionic is a popular framework for building hybrid mobile applications using web technologies like HTML, CSS, and JavaScript. It differs from React Native as it focuses on web technologies and uses Cordova or Capacitor to access native device features.
NativeScript is an open-source framework for developing truly native mobile applications using JavaScript, TypeScript, Vue.js, or Angular. It provides direct access to native APIs and performance similar to React Native, but it allows for a broader choice of frameworks for building the UI.
React Native Packager is a project similar in scope to browserify or webpack, it provides a CommonJS-like module system, JavaScript compilation (ES6, Flow, JSX), bundling, and asset loading.
The main difference is the Packager's focus on compilation and bundling speed. We aim for a sub-second edit-reload cycles. Additionally, we don't want users -- with large code bases -- to wait more than a few seconds after starting the packager.
The main deviation from the node module system is the support for our
proprietary module format known as @providesModule
. However, we
discourage people from using this module format because going forward we
want to completely separate our infrastructure from React Native and
provide an experience most JavaScript developers are familiar with,
namely the node module format. We want to even go further, and let you
choose your own packager and asset pipeline or even integrate into
your existing infrastructure.
React Native users need not to understand how the packager work, however, this documentation might be useful for advanced users and people who want to fix bugs or add features to the packager (patches welcome!).
The main way you'd interact with the packager is via the HTTP interface. The following is the list of endpoints and their respective functions.
Does the following in order:
path/to/moduleName
.js
suffix to the path.bundle
endpoint then the source map will be generated from that package.bundle
endpoint then
generate the source map.Note that source map generation currently assumes that the code has been compiled with jstransform, which preserves line and column numbers which allows us to generate source maps super fast.
You can pass options for the bundle creation through the query params,
if the option is boolean 1/0
or true/false
is accepted.
Here are the current options the packager accepts:
dev
boolean, defaults to true: sets a global __DEV__
variable
which will effect how the React Native core libraries behave.minify
boolean, defaults to false: whether to minify the bundle.runModule
boolean, defaults to true: whether to require your entry
point module. So if you requested moduleName
, this option will add
a require('moduleName')
the end of your bundle.inlineSourceMap
boolean, defaults to false: whether to inline
source maps.This is a page used for debugging, it offers a link to a single page :
The packager is made of two things:
ReactPackager is how you mainly interact with the API.
var ReactPackager = require('./react-packager');
Returns a function that can be used in a connect-like middleware. Takes the following options:
projectRoots
array (required): Is the roots where your JavaScript
file will existblacklistRE
regexp: Is a patter to ignore certain paths from the
packagerpolyfillModuleName
array: Paths to polyfills you want to be
included at the start of the bundlecacheVersion
string: used in creating the cache fileresetCache
boolean, defaults to false: whether to use the cache on
disktransformModulePath
string: Path to the module used as a
JavaScript transformernonPersistent
boolean, defaults to false: Whether the server
should be used as a persistent deamon to watch files and update
itselfassetRoots
array: Where should the packager look for assetsgetTransformOptionsModulePath
string: Path to module that exports a function
that acts as a middleware for generating options to pass to the transformer
based on the bundle and module being transformed.Build a package from a url (see the .bundle
endpoint). options
is
the same options that is passed to ReactPackager.middleware
Given an entry point module. Recursively collect all the dependent
modules and return it as an array. options
is the same options that
is passed to ReactPackager.middleware
To get verbose output when running the packager, define an environment variable:
export DEBUG=ReactNativePackager:*
You can combine this with other values, e.g. DEBUG=babel,ReactNativePackager:*
. Under the hood this uses the debug
package, see its documentation for all the available options.
The /debug
endpoint discussed above is also useful.
Yes. It's not really tied to React Native, however feature development is informed by React Native needs.
We love webpack, however, when we tried on our codebase it was slower than our developers would like it to be. You can find more discussion about the subject here.
FAQs
A framework for building native apps using React
The npm package react-native receives a total of 2,050,153 weekly downloads. As such, react-native popularity was classified as popular.
We found that react-native demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 7 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.