Easily generate react components and their the corresponding directories and files using configs created from snippets.
https://atom.io/packages/react-component-generator
or
$ cd ~/.atom/packages
$ git clone [email protected]:Eldwick/atom-react-component-generator.git
$ cd atom-react-component-generator
$ apm install
$ apm link
- name [String]
- Name of React Component. Will be used for file name and directory name if applicable
- type [String]
- (default) 'smart'/'s' uses the
class Component extends React.Component {
syntax - 'dumb'/'d' uses the
const Component = (props) => {
syntax
- (default) 'smart'/'s' uses the
- isCollection [bool]
- not applicable for root level component
- creates a
render[NameOfComponent]s
method on it's parent
- subcomponents [Array]
- imports all subcomponents into parent file
- if supplied will create a directory for the Parent and export itself using an
index.js
file
- Use
grc
thenTab
to generate a template config object.
- '⌘-⌥-^-g' : Use selected config object to generate file.
- Deeply Nested Components
- Sibling Components
{
name: 'GrandParent',
subcomponents: [{
name: 'Parent',
subcomponents: [{
name: 'Child',
type: 'd'
}, {
name: 'PartOfCollection',
isCollection: true,
type: 'd'
}]
}]
}
- GrandParent
- GrandParent.module.js.jsx
- index.js
- Parent
- Parent.module.js.jsx
- Child.module.js.jsx
- PartOfCollection.module.js.jsx
- index.js
import Parent from '/example/GrandParent/Parent'
class GrandParent extends React.PureComponent {
static propTypes = {
}
render() {
return (
<div>GrandParent</div>
)
}
}
export default GrandParent
import GrandParent from '/example/GrandParent/GrandParent'
export default GrandParent
import Child from '/example/GrandParent/Parent/Child'
import PartOfCollection from '/example/GrandParent/Parent/PartOfCollection'
class Parent extends React.PureComponent {
static propTypes = {
}
renderPartOfCollections() {
return COLLECTION.map(ELEMENT => <PartOfCollection />)
}
render() {
return (
<div>Parent</div>
)
}
}
export default Parent
const Child = (props) => {
return (
<div>Child</div>
)
}
Child.propTypes = {
}
export default Child
const PartOfCollection = (props) => {
return (
<div>PartOfCollection</div>
)
}
PartOfCollection.propTypes = {
}
export default PartOfCollection
import Parent from '/example/GrandParent/Parent/Parent'
export default Parent
˚