2.0.0 • Published 6 months ago

babel-plugin-react-native v2.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
6 months ago

Features

This plugin was created to allow tree-shaking when building for multiple react-native platforms.

Install

npm install --save-dev --save-exact babel-plugin-react-native

Example

Source:

import { Platform } from 'react-native';

if (Platform.OS === 'web') {
  console.log('web');
} else {
  console.log('not web');
}

Transformed to (with OS: "web"):

if ('web' === 'web') {
  console.log('web');
} else {
  console.log('not web');
}

Usage

Via babel.config.json

{
  "plugins": [["babel-plugin-react-native", { "OS": "web" }]]
}