Blog>
Snippets

Migrating createStore to configureStore

Show how to convert the Redux `createStore` function to the new `configureStore` API provided by Redux v5.0.0.
import { configureStore } from '@reduxjs/toolkit';

// Assume rootReducer and initialState are defined elsewhere
const store = configureStore({
  reducer: rootReducer,
  preloadedState: initialState
});

export default store;
This is the new way of creating a Redux store using the configureStore function from Redux Toolkit. replace the rootReducer with your combined reducers and initialize the store with initialState if needed.
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Redux Store</title>
</head>
<body>
    <div id="app"></div>
    <script src="path/to/your/bundled/script.js"></script>
</body>
</html>
HTML file that includes a div with id 'app' as the mount point for your React app and a script tag pointing to your bundled JavaScript file.
body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
    'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
    sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

div#app {
    padding: 1rem;
}
CSS styles for the HTML document. Setting the body to have zero margin and using a system font stack for better cross-platform compatibility. The div with id 'app' has padding applied for better appearance.