generator-rct
Version:
Scaffold React applications and its parts
61 lines (45 loc) • 1.7 kB
Markdown
> Scaffold React applications and its parts
First, install [Yeoman](http://yeoman.io) and generator-rct using [npm](https://www.npmjs.com/) (we assume you have pre-installed [node.js](https://nodejs.org/)).
```bash
npm install -g yo
npm install -g generator-rct
```
Then generate your new project:
```bash
yo rct
```
The generator generates TypeScript files with coresponding tests for following patterns:
React components
- Class Component
- SFC Component
- PureComponent
Smart React componet, uses connect and bindActionCreators
Redux reducers
- main reducer uses the object mapping pattern instead of a switch
- reducer function is meant to be connected to the main reducer
```
export const reducers: ReducerMap<State> = {
[]: replaceReducer,
[]: updateReducer,
[]: deleteReducer,
[]: errorReducer,
[]: requestReducer,
};
export const labelManagementReducer =
(state: State = initialState, action: StandardAction<any>) =>
getReducer<State>(reducers[action.type])(state, action);
```
it creates a reselect selector file.
redux action file, we expect to have a createAction within the system either from the redux-actions package or a custom implementation
redux saga pattern with option to listen for takeEvery or takAll and an example test
If you follow the single file function pattern us this generater to avoid those 20 seconds of typing :)