[英]React js - how to make a component context
How do i make a react component context?我如何制作反应组件上下文?
I manage to make it working, but happens that i`m unable to achieve this by the lack of understanding react.我设法使它工作,但碰巧我由于缺乏理解反应而无法实现这一目标。
I'll share my code.我会分享我的代码。 I want to do a 4 page components, apearing inside the main page.我想做一个 4 页面组件,在主页面内显示。 And as soon as i click on a new link, the set of 4 pages, change to a new set.一旦我点击一个新链接,这组 4 个页面,就会变成一个新的集合。 But not using routing, only using context.但不使用路由,只使用上下文。
Is that possible?那可能吗? Link to sample on code sandbox: Codesandbox example代码沙箱示例链接: Codesandbox 示例
I think your case is valid.我认为你的情况是有效的。 But a hook isn't a context, so you are right, you need to turn useTransistorInit
into a context like object.但是钩子不是上下文,所以你是对的,你需要将useTransistorInit
变成像 object 这样的上下文。
I recently helped someone with similar concern, you can take a look here.我最近帮助了一个有类似问题的人,你可以看看这里。 How to Get Back Data which was get filtered (ReactContextAPI) 如何取回被过滤的数据(ReactContextAPI)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.