npm install @reduxjs/toolkit react-redux
> npm install @reduxjs/toolkit react-redux
# then follow along from here to install RTK to codebase
# https://redux-toolkit.js.org/tutorials/quick-start#create-a-redux-store
If you are installing redux in an existing react project,
please be sure alter the index.js file to include the provider and
store from the redux module and app folder respectively.
yarn add @reduxjs/toolkit
// with template
yarn add @reduxjs/toolkit react-redux
yarn add @reduxjs/toolkit react-redux
// store.js
import { configureStore } from '@reduxjs/toolkit'
export const store = configureStore({
reducer: {},
})
// index.js
import { store } from './app/store'
import { Provider } from 'react-redux'
ReactDOM.render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById('root')
)
// Redux + Plain JS template
npx create-react-app my-app --template redux
// Redux + TypeScript template
npx create-react-app my-app --template redux-typescript
createAction('tagsLoadSuccess', (tags: string[]) => {
return {
payload: tags,
};
})