Skip to content
This repository has been archived by the owner on Jun 27, 2019. It is now read-only.

sibs-projects/codemod-RN24-to-RN25

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README

Why this transform is necessary?

Until React Native 24, you import React from 'react-native' package, but this will change in RN 25, you will need to import React from 'react', and also all the other React exports like Component, PropTypes, Children and so on. You probably have many files that does this, so I've created a codemod to save you a bunch of time

How to use this

  1. Install jscodeshift
  2. Download this transform
  3. Navigate to the directory
  4. Run the transform
# 1
npm install -g jscodeshift

# 2, 3
git clone https://github.com/sibeliusseraphini/codemod-RN24-to-RN25.git && cd codemod-RN24-to-RN25

# 4.
jscodeshift PATH_TO_FILES

Example

import React, {
  Component,
  View,
  Text,
  StyleSheet,
  TouchableHighlight,
  TextInput,
  PropTypes,
} from 'react-native';
import NavigationBar from 'react-native-navbar';


class LoginScreen extends Component {
  render() {
    return (
      <View>
        <NavigationBar
          tintColor="#ADF8D1"
        />
      </View>
    );
  }
}

Will be transformed to:

import React, {Component, PropTypes} from "react";
import {View, Text, StyleSheet, TouchableHighlight, TextInput} from "react-native";
import NavigationBar from 'react-native-navbar';

class LoginScreen extends Component {
  render() {
    return (
      <View>
        <NavigationBar
          tintColor="#ADF8D1"
        />
      </View>
    );
  }
}

Recast Options

Options to recast's printer can be provided through the printOptions command line argument. See the full list of options here.

jscodeshift PATH_TO_FILES --printOptions='{"quote":"double"}'

About

A simple codemod to handle the new import style on RN25

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published