Quantcast
Channel: Active questions tagged react-native+typescript - Stack Overflow
Viewing all articles
Browse latest Browse all 6287

How can i assignable to parameter of type payload in TypeScript?

$
0
0

I'm using react native with TypeScript and redux-toolkit

in my following code this typescript error occured

  Expected 0 arguments, but got 1

enter image description here

i'm not sure which code should fix. i think this error is TypeScript errorHow can i fix my code?

signup.ts

const SignUp = () => { const hi = useCallback(() => {dispatch(login({email:'test'})); }, [dispatch, email]);} 

action.ts

        export const login = createAsyncThunk('user/login',      async (data, {rejectWithValue}) => {        try {          const response = await axios.post('/user/login', data);          return response.data;        } catch (error) {          // return rejectWithValue(error.response.data);        }      },    );

slice.ts

    export const initialState = {      email: '',      me: null,      userInfo: null,      loginLoading: false, // 로그인시도중      loginDone: false,      loginError: null,    };    const userSlice = createSlice({      name: 'user',      initialState,      reducers: {},      extraReducers: builder =>        builder          .addCase(login.pending, state => {            state.loginLoading = true;            state.loginDone = false;            state.loginError = null;          })          .addCase(login.fulfilled, (state, action) => {            state.loginLoading = false;            state.me = action.payload;            state.loginDone = true;          })          .addCase(login.rejected, (state, action) => {            state.loginLoading = false;            // state.loginError = action.payload;          }),    });

Viewing all articles
Browse latest Browse all 6287

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>