我有一个关于在包装父组件的render函数中访问子组件返回值的问题。我想“操纵”子组件的外观……
<ResponsiveWrapper>
<PersonalData/>
<LoginData/>
</ResponsiveWrapper>
ResponsiveWrapper
问题在于,ResponsiveWrapper的子代在其渲染函数中是这样的:
$$typeof: Symbol(react.element)
key: null
props: {}
ref: null
type: ƒ PersonalData()
_owner: FiberNode {tag: 0, key: null, elementType: ƒ, type: ƒ, stateNode: null, …}
_store: {validated: true}
_self: null
_source: null
__proto__: Object
$$typeof: Symbol(react.element)
key: null
props: {}
ref: null
type: ƒ LoginData()
_owner: FiberNode {tag: 0, key: null, elementType: ƒ, type: ƒ, stateNode: null, …}
_store: {validated: true}
_self: null
_source: null
__proto__: Object
length: 2
__proto__: Array(0)
...但是我想要这个。我需要由PersonalData和LoginData呈现的元素:
$$typeof: Symbol(react.element)
key: null
props: {head: "Akkordeon", right: {…}, children: Array(2), className: "", dataGroup: null, …}
ref: null
type: ƒ Accordion(props)
_owner: FiberNode {tag: 1, key: null, elementType: ƒ, type: ƒ, stateNode: App, …}
_store: {validated: true}
_self: null
_source: null
__proto__: Object