I created new React&Redux project with npx create-react-app my-app --template redux
.
From below code i getting following Error: Parsing error: Invalid parenthesized assignment pattern.
After switching arrow function to expression everything works fine.
import { createSlice } from '@reduxjs/toolkit';
export const movieSlice = createSlice({
name: "movie",
initialState: { value: { title: "", descripion: "" } },
reducers: {
getMovies: (state, action) = () => {
state.value = action.payload;
}
}
});
export default movieSlice.reducer;
CodePudding user response:
you have added and extra () = by mistake i guess. Here is the solution
import { createSlice } from '@reduxjs/toolkit';
export const movieSlice = createSlice({
name: "movie",
initialState: { value: { title: "", descripion: "" } },
reducers: {
getMovies: (state, action) => {
state.value = action.payload;
}
}
});
export default movieSlice.reducer;