代码之家  ›  专栏  ›  技术社区  ›  Adam

使用重组setStatic并将其连接到redux(nextjs)

  •  1
  • Adam  · 技术社区  · 7 年前

    我正在使用下面的作文,并期待 a 作为道具传递。但它还没有定义。

    请问怎么修?

    import { setStatic, compose } from 'recompose'
    import { connect } from 'react-redux'
    
    export const getInitialProps = function() {
      console.log(this.props.a);
    }
    
    const mapDispatchToProps = (dispatch) => ({
      a: url => dispatch({type: 'a'})
    })
    
    export default compose(
      connect(null, mapDispatchToProps),
      setStatic('getInitialProps', getInitialProps),
    )
    
    1 回复  |  直到 7 年前
        1
  •  0
  •   Adam    7 年前

    调查结果如下: getInitialProps componentDidMount 生命周期