project_mern_memories icon indicating copy to clipboard operation
project_mern_memories copied to clipboard

Compiled with warnings when running the client

Open franc82 opened this issue 3 years ago • 5 comments

when running the client, i am getting the following error:

Compiled with warnings.

src/reducers/posts.js Line 3:1: Assign arrow function to a variable before exporting as module default import/no-anonymous-default-export

Search for the keywords to learn more about each warning. To ignore, add // eslint-disable-next-line to the line before.

franc82 avatar Jan 27 '21 22:01 franc82

I have same error

mika1407 avatar Jan 28 '21 03:01 mika1407

6b9dd015-45b2-44a9-a008-8973fc1cabac

i m also getting same warning with this issue

laxmi2230 avatar Jan 29 '21 07:01 laxmi2230

add variable to your function:

export default const variable = (posts = [], action) => {
    switch (action.type) {
        case FETCH_ALL:
            return action.payload;
        case UPDATE:
            return posts.map((post) => post._id === action.payload._id ? action.payload : post);
        case CREATE:
            return [ ...posts, action.payload];
        case DELETE:
            return posts.filter((post) => post._id !== action.payload);
        default:
            return posts;
    }
}

JavaScript has to know what are you exporting, that's why the warning was there.

19sajib avatar Mar 16 '21 06:03 19sajib

Respected Sir, Sir still i am not able to do it

https://github.com/laxmi2230/Memories_bring_back_you_

This is my github link for that project(in which Molu folder is for frontend part and Laxmi folder is for backend part)

Please help. With regards.

On Tue, 16 Mar 2021 at 12:10, Sajib @.***> wrote:

add variable to your function:

export default const variable = (posts = [], action) => { switch (action.type) { case FETCH_ALL: return action.payload; case UPDATE: return posts.map((post) => post._id === action.payload._id ? action.payload : post); case CREATE: return [ ...posts, action.payload]; case DELETE: return posts.filter((post) => post._id !== action.payload); default: return posts; } }

JavaScript has to know what are you exporting, that's why the warning was there.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/adrianhajdin/project_mern_memories/issues/12#issuecomment-799997192, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALD6FD3QRMVGLJRRAJISLWDTD34PTANCNFSM4WWBTLIA .

laxmi2230 avatar Mar 22 '21 06:03 laxmi2230

Hello, had the same issue, handled it with following code :

const posts = (posts = [], action) => {
    switch (action.type) {
        case 'FETCH_ALL':
            return action.payload;

        case 'CREATE':
            return [...posts, action.payload];
    
        default:
            return posts;
    }
};

export default posts;

Regards

kroyoda avatar Jun 26 '21 11:06 kroyoda