Taro 3.2 React Native Support: Faster Compilation, Source‑Map, Multi‑Version Compatibility, Rich API, On‑Demand Import, and Integration Guide
The article introduces Taro 3.2's React Native support, detailing faster compilation via Metro, native source‑map debugging, compatibility with React Native 0.60+ (including 0.64), expanded APIs and components, on‑demand imports to reduce bundle size, and step‑by‑step migration and integration instructions.
Taro is an open‑source cross‑platform framework that enables developers to build applications for mini‑programs, H5, and React Native using frameworks such as React, Vue, or Nerv. Since the release of Taro 3, the 58 team partnered with Taro to add official React Native support, culminating in the 3.2 stable version.
Highlights
1. Faster Compilation Speed
Previous Taro versions generated intermediate code before Metro bundled the React Native bundle, resulting in slower builds. Taro 3 React Native now skips the intermediate step and lets Metro directly bundle the source, leveraging multi‑level caching and hasteFS for significantly faster compilation.
Metro bundling with caching accelerates build times.
Better alignment with the React Native ecosystem simplifies community optimizations.
2. Source‑Map Support
Eliminating intermediate code also enables native source‑map generation, providing debugging experiences identical to pure React Native projects.
3. Support for Multiple React Native Versions (≥0.60, including 0.64)
The framework now adapts to the React Native version specified in the project, automatically supporting the latest 0.64 features such as Hermes, inline requires, and React 17.
Upgrade Instructions
react: ^17.0.0
react-dom: ^17.0.0
typescript: ^4.1.0
@typescript-eslint/parser: ^4.15.1
@typescript-eslint/eslint-plugin: ^4.15.1
react-native: ^0.64.0
ESLint configuration example:
// .eslintrc
module.exports = {
"extends": ["taro/react"],
"rules": {
"react/jsx-uses-react": "off",
"react/react-in-jsx-scope": "off"
}
}4. Richer API and Component Set
Taro 3.2 adds 45 new APIs and 8 new components, including multimedia, scanning, and virtual list capabilities, narrowing the gap between React Native and other Taro targets.
Sample new APIs include scanCode , show/hideTabBar , and createCameraContext . New components include Video , Camera , and VirtualList .
5. On‑Demand Import
To reduce bundle size, Taro now supports tree‑shaking of unused APIs and components. Example:
import Taro from '@tarojs/taro'
Taro.scanCode(options)
// After bundling, only the used API is imported:
// import { scanCode } from '@tarojs/taro-rn/dist/lib/scanCode'6. Seamless Integration with Existing React Native Projects
By providing a custom Metro transformer and runtime adapters, Taro can be merged into an existing React Native Metro configuration without altering business code.
// metro.config.js example
const Supporter = require('@tarojs/rn-supporter')
const supporter = new Supporter()
const taroMetroConfig = supporter.getMetroConfig()
const busConfig = { resetCache: true }7. Use Without Cross‑Platform Needs
Even developers focusing solely on React Native can benefit from Taro’s fast iteration, unified APIs, and simplified styling.
Upgrade Guide
For v3.x projects, install the latest CLI, clean node_modules, and update Taro dependencies to ^3.2.0.
npm i -g @tarojs/cliFuture plans include further expanding API coverage, improving developer experience, and adding more tutorials and examples.
For more details, refer to the linked documentation and migration guides.
58 Tech
Official tech channel of 58, a platform for tech innovation, sharing, and communication.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.