sibs-projects / Codemod Rn24 To Rn25
A simple codemod to handle the new import style on RN25
Stars: ✭ 103
Programming Languages
javascript
184084 projects - #8 most used programming language
Labels
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
- Install jscodeshift
- Download this transform
- Navigate to the directory
- 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"}'
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].