Redux | Async | Can';我不明白为什么分派功能是';行不通

Redux | Async | Can';我不明白为什么分派功能是';行不通,redux,redux-thunk,Redux,Redux Thunk,我不明白为什么我的action creator中的dispatch函数没有运行。我已经在我的商店里导入了redux thunk,因为它是一个异步函数 import axios from 'axios' import { LOG_IN } from './types' export function signup ({email, password}) { console.log('signup function ran') // THIS RUNS return functio

我不明白为什么我的action creator中的dispatch函数没有运行。我已经在我的商店里导入了redux thunk,因为它是一个异步函数

import axios from 'axios'
import { LOG_IN } from './types'

export function signup ({email, password}) {
    console.log('signup function ran') // THIS RUNS
    return function (dispatch) {
        console.log('dispatch function ran') // THIS DOES NOT RUN, NOR DOES ANYTHING BELOW
        axios
        .post('https://MYAPI.com/signup', {email, password})
        .then(response => dispatch({
            type: LOG_IN,
            payload: response.data.token
        }))
        .catch(error => {
            console.log(error)
        })
    }
} 

我从来没有弄明白为什么在函数中返回函数不起作用,但是下面的代码确实起作用(我将所做的更改加粗)。如果有人能告诉我为什么第一个不起作用,我会很高兴:)


我从来没有弄明白为什么在函数中返回函数不起作用,但是下面的代码确实起作用(我将所做的更改加粗)。如果有人能告诉我为什么第一个不起作用,我会很高兴:)

import axios from 'axios'
import { LOG_IN } from './types'
import store from '../store' // I IMPORTED THE STORE

export function signup ({email, password}) {
    console.log('singup function ran')
        axios
        .post('https://MYAPI/signup', {email, password})
        .then(response => store.dispatch({  // I SPECIFICALLY CALLED THE STORE HERE
            type: LOG_IN,
            payload: response.data.token
        }))
        .catch(error => {
            console.log(error)
        })
}