标签: javascript reactjs react-redux react-router
假设我有一个component1,它的状态要与component2共享,现在component2是由按钮组件(不是html按钮)通过使用useHistory挂钩呈现的。现在使用上下文API,我的按钮组件可以通过使用上下文提供程序来访问component1的状态,但是如何从component2访问状态。所有组件都是功能组件。