亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

是否可以使用 HOC 將字符串數組作為參數傳遞?

是否可以使用 HOC 將字符串數組作為參數傳遞?

森林海 2021-06-15 17:08:14
我在我的 nextJS 應用程序中使用了一些 HOC 組件來通過getInitialProps. 但是我需要為這些道具使用動態值。在我的索引組件中,我正在調用withServerProps. 是否可以將一些字符串數組傳遞給它?索引.jsimport React, { Component } from 'react'import { withTranslation } from 'i18n'import withServerProps from 'with-server-props'class Index extends Component {  render () {    return (<div>Some content</div>)  }}export default withServerProps( // <-- How to pass an array with strings?  withTranslation()(Index) )我需要在這個函數中獲取字符串數組:with-server-props.jsimport React, { Component } from 'react'export default WrappedComponent =>  class extends Component {    static async getInitialProps (context) {      const { query } = context      return {        id: query && query.id        target: PASSED_ARRAY // <-- Need to recieve the array here      }    }    render () {      return <WrappedComponent {...this.props} />    }  }
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 142 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號