百度, componentDidShow 方法内,redux通过@connent函数绑定方法,没有生效,到willMount才能生效



  • 问题描述
    百度, componentDidShow 方法内,redux通过@Connent函数绑定的方法,没有获取到,到willMount才能获取到

    复现步骤
    正常页面,componentDidShow方法内,都获取不到

    示例代码:
    import { initCity } from '@actions/city'

    @connect(state => ({
    ...state.home,
    }), {
    initCity
    })
    class Home extends Component {
    componentDidShow() {
    this.props.initCity()
    }
    }
    期望行为
    在页面 componentDidShow 方法中能获取到 关联到props上的action函数

    报错信息
    index.js:163 Uncaught (in promise) TypeError: this.props.initCity is not a function
    屏幕快照 2020-05-13 上午11 42 02

    系统信息
    Taro CLI 2.1.5 environment info:
    System:
    OS: macOS 10.14.6
    Shell: 3.2.57 - /bin/bash
    Binaries:
    Node: 12.16.3 - /usr/local/bin/node
    Yarn: 1.19.1 - /usr/local/bin/yarn
    npm: 6.14.4 - /usr/local/bin/npm
    npmPackages:
    @tarojs/async-await: 1.3.37 => 1.3.37
    @tarojs/components: 1.3.37 => 1.3.37
    @tarojs/plugin-babel: 1.3.37 => 1.3.37
    @tarojs/plugin-csso: 1.3.37 => 1.3.37
    @tarojs/plugin-uglifyjs: 1.3.37 => 1.3.37
    @tarojs/redux: 1.3.37 => 1.3.37
    @tarojs/redux-h5: 1.3.37 => 1.3.37
    @tarojs/router: 1.3.37 => 1.3.37
    @tarojs/taro: 1.3.37 => 1.3.37
    @tarojs/taro-alipay: 1.3.37 => 1.3.37
    @tarojs/taro-h5: 1.3.37 => 1.3.37
    @tarojs/taro-swan: 1.3.37 => 1.3.37
    @tarojs/taro-tt: 1.3.37 => 1.3.37
    @tarojs/taro-weapp: 1.3.37 => 1.3.37
    @tarojs/webpack-runner: 1.3.37 => 1.3.37
    eslint-config-taro: 1.3.37 => 1.3.37
    eslint-plugin-taro: 1.3.37 => 1.3.37
    nerv-devtools: ^1.5.6 => 1.5.6
    nervjs: ^1.5.6 => 1.5.6
    stylelint-config-taro-rn: 1.3.37 => 1.3.37
    stylelint-taro-rn: 1.3.37 => 1.3.37
    taro-ui: ^2.2.4 => 2.3.4

    补充信息
    redux的函数绑定过于滞后


登录后回复