Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

234
Views
slice reducer for key "pageName" returned undefined during initialization

I am creating redux app using createSlice(), but get the error:

Error: The slice reducer for key "pageName" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.

Here is the minimal example for this error.

pageNameSlice.js:

import { createSlice } from "@reduxjs/toolkit";

const pageNameSlice = createSlice({
    name: 'pageName',
    initalState: "",
    // The `reducers` field lets us define reducers and generate associated actions
    reducers: {
      setPageName: (state, newName) => {
          state.pageName = newName
      }
    }
});

export default pageNameSlice.reducer;

store.js:

import { configureStore } from '@reduxjs/toolkit';
import pageNameReducer from '../features/pageNameSlice';

export const store = configureStore({
  reducer: {
    pageName: pageNameReducer
  },
});
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You have a typo there - initalState should be initialState. (This is more common than you might think ^^)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!