
[英]React: update component's props from outside of render method without using state
[英]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.