generator-react-domain
This Generator helps you create connected React components with the Domain file structure ❄️
$ tree.├── Component.fixtures.js├── Component.js├── ComponentActions.js├── ComponentConstants.js├── ComponentHelper.js├── ComponentReducer.js├── ComponentSelectors.js├── __tests__│ ├── Component.test.js│ ├── ComponentActions.test.js│ ├── ComponentIntegration.test.js│ ├── ComponentReducer.test.js│ └── ComponentSelectors.test.js├── component.scss└── index.js
Usage
# install npm install --global yo generator-react-domain # run it # destination # name yo react-domain src/components ComponentName
Options
--redux
- Create Redux files.
Tests
This generator is using an external package called react-redux-test-utils to create light and readable test templates for your components. The package uses enzyme
at its core.
Config
create a .yo-rc.json
file in your project's root folder and fill it:
Replacing Templates
To learn how to create Templates, refer to ejs.co
- fill your
.yo-rc.json
file in your project's root folder withtemplatesPath
as seen above.
- Put supported files in your templates folder, make sure to be case-sensitive.
File | Description | Has Template |
---|---|---|
Component.js | Component | ✅ |
Component_test.js | Component Test | ✅ |
Actions.js | Redux Actions | ✅ |
Actions_test.js | Actions Test | ✅ |
Reducer.js | Redux Reducer | ✅ |
Reducer_test.js | Reducer Test | ✅ |
Selectors.js | Redux Selectors | ✅ |
Selectors_test.js | Selectors Test | ✅ |
index.js | Index file | ✅ |
Integration_test.js | Redux Flow Test | ✅ |
Constants.js | Constants | ✅ |
Helper.js | Helper methods | |
Scss.js | SCSS File | |
Fixtures.js | Fixtures/Mocks |
All Templates receive the following props
<%= name %> # Pascal case name <%= name_upper %> # Capitalized name <%= name_lower %> # Camel case name