lore-generate-component
Generates a new React component in src/components
Generates a new React component in src/components
You can change which version of ES the component is generated in by passing in a language flag. By default, components are generated in ES5
syntax.
lore generate component MyComponent --es5
lore generate component MyComponent --es6
lore generate component MyComponent --esnext
import React from 'react';
import createReactClass from 'create-react-class';
import PropTypes from 'prop-types';
export default createReactClass({
displayName: 'MyComponent',
propTypes: {},
render() {
return (
<div></div>
);
}
});
import React from 'react';
import PropTypes from 'prop-types';
class MyComponent extends React.Component {
constructor(props) {
super(props);
// Set your initial state here
// this.setState = {};
// Bind your custom methods so you can access the expected 'this'
// this.myCustomMethod = this.myCustomMethod.bind(this);
}
render() {
return (
<div></div>
);
}
}
MyComponent.propTypes = {};
export default MyComponent;
import React from 'react';
import PropTypes from 'prop-types';
class MyComponent extends React.Component {
static propTypes = {};
constructor(props) {
super(props);
// Set your initial state here
// this.setState = {};
// Bind your custom methods so you can access the expected 'this'
// this.myCustomMethod = this.myCustomMethod.bind(this);
}
render() {
return (
<div></div>
);
}
}
export default MyComponent;