project_mern_memories
project_mern_memories copied to clipboard
Compiled with warnings when running the client
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.
I have same error
i m also getting same warning with this issue
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.
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 .
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