Convert import React, { Component } from 'react-native' to import React, { Component } from 'react'
// find and update all import React, { Component } from 'react-native'
root
.find(j.ImportDeclaration, {
source: {
value: 'react-native'
}
})
.filter(({node}) => {
// check React or { Component } from 'react-native'
const nodes = node.specifiers.filter(imports => {
return imports.type === 'ImportDefaultSpecifier' && imports.local.name === 'React' ||
imports.type === 'ImportSpecifier' && imports.local.name === 'Component';
});
return nodes.length > 0;
})
.forEach(updateImport);