Я использую некоторые компоненты HOC в своем приложении nextJS, чтобы установить некоторые значения пропуска при помощи getInitialProps
.
Но мне нужно использовать динамические значения для этих реквизита.
В моем компоненте индекса я звоню withServerProps
. Можно ли передать ему какой-нибудь строковый массив?
index.js
import 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)
)
Мне нужно получить массив строк в этой функции:
с-сервер props.js
import 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} />
}
}