dispatching an asyncThunk function from my component doesn’t work

  Kiến thức lập trình

My Component:

const dispatch = useDispatch();
const getMyMovements = (page) => {
    console.log('here????')
    dispatch(handleGetMyMovements(page))
}

useEffect(() => {
    getMyMovements(page)
}, [page])

My slice file:

export const handleGetMyMovements = createAsyncThunk('myMovements/handleGetMyMovements', async(page) => {
    try{
        console.log('and here?')
        const {data} = await getRequest(`/coach/motion/${page}`)
        console.log('in thunk', data)
        return data
    }
    catch(err){
        console.error('err',err)
    }
})

const myMovementsSlice = createSlice({
    name: 'myMovements',
    .
    .
    .

I can’t understand what’s the problem, as you see I have some log and here??? appears in console but two other logs in my asyncThunk don’t.

LEAVE A COMMENT