Why this transform is necessary?
Until React Native 24, you import React from 'react-native' package, but this will change on RN 25, you will need to import React from 'react'. You probably have many files that does this, so I've created a codemod to save you a bunch of time
- Install jscodeshif
npm install -g jscodeshift
- Download this transform
- Run the transform
jscodeshift -t transform.js FILES
import React, {
Component,
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>
);
}
}
Will be transformed to:
import React, {Component} 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>
);
}
}