繁体   English   中英

从渲染道具组件获取状态

[英]get state from render props component

我有一个渲染道具手风琴组件

this.props.children({open: this.state.open})

在render()中

然后在其他地方我可以像这样使用它

<Accordion>
  {({ open }) => {
    console.log(open) //true or false

    return (
      <>something here</>
    )
  }}
</Accordion>
{open.toString()} //open is not accessible here

但是如何访问render props函数之外的代码?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM