React
VS Code snippets for React development in CommonJS syntax
Why?
Same Reactjs code snippets extension but modified to work with Node.js
Changes
ES6 Imports to CommonJS
import React from 'react';
const React = require('react');
import React, { Component } from 'react';
const React = require('react');
import React, { PureComponent } from 'react';
const React = require('react');
import PropTypes from 'prop-types';
const PropTypes = require('prop-types');
import { connect } from 'react-redux';
const { connect } = require('react-redux');
Rename Class definition
class componentName extends Component
class componentName extends React.Component
class componentName extends PureComponent
class componentName extends React.PureComponent
Convert mapStateToProps to arrow function
function mapStateToProps(state) {
return {};
}
const mapStateToProps = state => ({});
Convert ES6 Export to CommonJS
export default componentName;
module.exports = componentName;
export default connect(mapStateToProps)(componentName);
module.exports = connect(mapStateToProps)(componentName);