WhoBuilt

Scaffolding plugins for React Native

Sep 14, 2018· 9 min· 101 views·Watch on YouTube

Speaker

Johannes Stein of Callstack explains how to scaffold shareable native modules for React Native and reduce repetitive setup.

Why automate native module setup

Stein describes how JavaScript can take an app far, but some features require native code. Creating and extracting a module for sharing is manageable once, but repetitive when done several times.

Generate a cross-platform library

React Native Create Library generates a module from a Hello World example. Its scaffold includes Android, iOS, and Windows folders, plus a package and README. Stein adds a `helloWorld` method on iOS and Android that logs a message.

Publish and link the module

The tool supports iOS, Android, and Windows, and produces a library ready to publish with `npm publish`. In a React Native project, developers can install the package, run `react-native link`, then import the module and call its method.

Use prefixes to avoid collisions

The generator defaults to the `RN` prefix but recommends choosing initials or another distinctive prefix to reduce naming collisions. It rejects `RCT`, which Stein says is reserved for React Native core modules.

Generate modules inside an app

The tool can be installed as a development dependency and used to create a module folder inside an app, though developers must link it manually. Stein points to `react-native-create-bridge` as a more capable alternative, with UI modules and Swift and Kotlin support.

Takeaways

  • Automate repeated native-module scaffolding to make library creation more consistent.
  • Check which platforms a generator scaffolds before adopting it; this tool supports iOS, Android, and Windows.
  • Choose a distinctive native prefix to reduce naming collisions, and avoid reserved prefixes such as `RCT`.
  • Confirm how generated modules are linked inside an app; this tool requires manual linking for that workflow.
  • Compare generators by their needs: `react-native-create-bridge` also supports UI modules, Swift, and Kotlin.

Mentioned in this talk

Search inside this talk

What was claimed 8

Related talks

Scaffolding plugins for React Native, Johannes Stein · WhoBuilt