# Reducers

Reducers can be generated by running `hatch reducer <moduleName>`

Reducers are simply [Redux reducers](https://redux.js.org/basics/reducers). For the best developer experience, reducers
should be defined using the `defineReducer` module in `hatch-web`. As an example:

```typescript
import {defineReducer} from '@launchtray/hatch-web';
import actions from '../actions/index';

export default defineReducer({
  numberState: 97,
  stringState: '',
})
  .on(actions.exampleAction, (state, payload) => {
    return {
      ...state,
      stringState: payload.stringField,
    };
  })
  .on(actions.exampleAction2, (state, payload) => ({
    ...state,
    numberState: payload.numberField,
  }));
```

Using this module adds type safety.