Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 978 Bytes

readme.md

File metadata and controls

29 lines (22 loc) · 978 Bytes

jscodemods

Scripts to be used with JSCodeshift

React import namespace

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;