Scripts to be used with JSCodeshift
Because React.js has no default export (it is not an es6 module),
it should be imported like this: import * as React from 'react';
or like this: var React = require('react');
.
See here for more information.
This codemod rewrites all react imports to namespace import statements
and creates destructuring assignments on the imported namespace for named imports.
This:
import React, {Component, PropTypes} from 'react';
becomes this:
import * as React from 'react';
const {Component, PropTypes} = React;