i'm new with TypeScript. I'm trying to use TypeScript with Redux but i'm blocked with this error: Property 'user' does not exist on type 'WritableDraft<{ name: string; }>'.
I was going step by step with tutorial on Youtube but it's not working on my project. Any ideas?
Here's my code:
import { createSlice } from '@reduxjs/toolkit';
import React from 'react';
export const userSlice = createSlice({
name: 'user',
initialState: {
name: '',
},
reducers: {
login: (state, action) => {
state = action.payload;
},
logout: (state) => {
state.user = null;
},
},
});
export const { login, logout } = userSlice.actions;
export const selectUser = (state: { user: { user: any } }) => state.user.user;
export default userSlice.reducer;