Why am I getting the following error while trying to create a store with redux-toolkit?
Uncaught TypeError: setting getter-only property "configureStore"
This is my scr/store/index.js
:
import { configureStore } from "@reduxjs/toolkit";
import uiSlice from "./ui-slice";
const store = configureStore = ({
reducer: {
ui: uiSlice.reducer
}
})
export default store;
And this is my src/index.js
import ReactDOM from 'react-dom/client';
import { Provider } from 'react';
import './index.css';
import App from './App';
import store from './store/index';
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<Provider store={store}>
<App />
</Provider>
);
I've followed redux-toolkit
documentation as I did previously in other projects and I never had this error before. Am I omitting something?
this line: const store = configureStore = ({
is either some new JS syntax that I don't know or a syntax error.
try this:
const store = configureStore({
reducer: {ui: uiSlice.reducer},
});