Javascript 将引用从父级(功能组件)向下传递到子级(类组件),然后向下传递到另一个子级(功能组件)

Javascript 将引用从父级(功能组件)向下传递到子级(类组件),然后向下传递到另一个子级(功能组件),javascript,reactjs,Javascript,Reactjs,const Container=props=>{ const ref=React.createRef() 返回( {props.flag?:} ) } 类搜索扩展组件{ componentDidMount(){ console.log(this.props.reference) } render(){ 返回( ) } } const JButton=React.forwardRef((props,ref)=>{ 返回( 你好 ) }) 我们无法帮助您处理无法看到的代码。:-)请使用演示问题的工

const Container=props=>{
const ref=React.createRef()
返回(
{props.flag?:}
)
}
类搜索扩展组件{
componentDidMount(){
console.log(this.props.reference)
}
render(){
返回(
)
}
}
const JButton=React.forwardRef((props,ref)=>{
返回(
你好
)
})


我们无法帮助您处理无法看到的代码。:-)请使用演示问题的工具更新您的问题,最好是使用堆栈片段(
[]
工具栏按钮)运行的工具。堆栈代码段支持React,包括JSX。请注意,这个例子应该是最小的,但应该说明问题。你提供的代码似乎可以工作:看起来一切都在工作,这是非常奇怪的。是的,它对我有效。你能说你的React版本吗?16.6.3。现在也为我工作@维克托卡斯特罗