我在我的 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} /> } }
添加回答
举报
0/150
提交
取消