Anonymous function declarations cause Fast Refresh to not preserve local component state

Viewed 110

I'm using redux with next js and this is my reducer.

const initialState = {
    navBarShow: false
}

export default function pageData(state = initialState, action) {

    switch (action.type) {

        case 'SET_NAV_BAR':
            return {
                ...state,
                navBarShow: action.payload
            }
        default: return state
    }

}

I'm calling it inside reducers index.js like this.

import { combineReducers } from "redux";

import pageData from './PageContents' 

export default combineReducers({
    pageData,
});

But I'm getting this error,

Anonymous function declarations cause Fast Refresh to not preserve local component state. C:\react\nextfinalcom\redux\reducers\PageContents.js Please add a name to your function, for example:

Before export default function () { /* ... */ }

After export default function Named() { /* ... */ }

A codemod is available to fix the most common cases: https://nextjs.link/codemod-ndc

Can it be a cache issue since I added a name?. Is there a way to clear cache?

0 Answers
Related