> For the complete documentation index, see [llms.txt](https://gpeterhand.gitbook.io/react/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gpeterhand.gitbook.io/react/redux/menyaem-store.md).

# Меняем Store

Создаем для Home файл с экшеном и редьюсером:

{% code title="src/scenes/Home/services.js" %}

```jsx
// Actions
const CHANGE_TEXT = 'CHANGE_TEXT'

// Reducer
const home = (state = {}, action) => {
  switch (action.type) {
    case CHANGE_TEXT:
      return { ...state, text: action.text }
    default:
      return state
  }
}

export { CHANGE_TEXT, home }
```

{% endcode %}

Подключаем редьюсер Home к корневому редьюсеру

{% code title="src/App/services.js" %}

```jsx
import { combineReducers } from 'redux'

// Reducers
import { home } from 'scenes/home/services'

const rootReducer = combineReducers({ home })

export default rootReducer
```

{% endcode %}

Добавляем к компоненту Home возможность диспатчить экшен

{% code title="src/scenes/Home/index.js" %}

```jsx
import { connect } from 'react-redux'
import Button from '@material-ui/core/button'

import { CHANGE_TEXT } from './services'

const Home = ({ text, dispatch }) => (
  <>
    <h1>Home</h1>
    <h2>{text}</h2>

    <Button
      variant="raised"
      onClick={() => dispatch({ type: CHANGE_TEXT, text: 'Text was changed!' })}
    >
      CHANGE TEXT
    </Button>
  </>
)

export default connect(({ home }) => ({ ...home }))(Hom
```

{% endcode %}

Теперь при нажатии на кнопку меняется Store и, соответственно, текст с "Hello, world!" на "Text was changed!"
