转发参考不适用于redux compose

时间:2019-01-22 01:41:42

标签: reactjs redux react-redux i18next react-i18next

当我将connect()和withI18n()与来自redux的compose结合使用时,forwardRef无法正常工作,

当我单独使用connect()与I18n()和compose()一起使用时,它工作得很好

const combine = compose (
  withI18n('defaltNamespace', {wait: true}),
  connect(mapStateToProps, { 
    startShowCarsAround, 
    startSearchCities, 
    startNewRide,
    startRecentRides,
    startCancelOrder
 }, null, {forwardRef:true})
)

export default combine(Order)

以这种方式在console.log(this.ref)(来自父组件im ref的console.log())中显示此内容

current: WithContext
 context: {}
 props: {cities: Array(8), user: {…}}
 refs: {}
 state: null
 updater: {isMounted: ƒ, enqueueSetState: ƒ, enqueueReplaceState: ƒ, 
 enqueueForceUpdate: ƒ}
 _reactInternalFiber: FiberNode {tag: 1, key: null, elementType: ƒ, type: ƒ, 
 stateNode: WithContext, …}
 _reactInternalInstance: {_processChildContext: ƒ}
 isMounted: (...)
 replaceState: (...)
 __proto__: Component
 __proto__: Object

例如显示该组件im ref的道具,这意味着它部分起作用,因为它没有显示我需要的功能。如我所说,它显示了当我仅使用connect()而没有使用i18n()

时的功能

0 个答案:

没有答案