Modal.confirm and other global popup component can't set redux HOC Connect as content
See original GitHub issueVersion
2.9.3
Environment
MacOS 10.11.6
Reproduction link
http://sorry.its.easy.to.reasoning
Steps to reproduce
Create a Redux HOC Connect and a dump component, in dump component attach a click event on a button, it will popup Modal.confirm. This confirm contains the HOC Connect.
What is expected?
The confirm dialog popup.
What is actually happening?
Console report: browser.js:40 Uncaught Error: Could not find "store" in either the context or props of "Connect(ModuleSelect)". Either wrap the root component in a <Provider>, or explicitly pass "store" as a prop to "Connect(ModuleSelect)".
ModuleSelect is the HOC Connect.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Confirmation modal connecting to redux store using ...
But as connected Confirmation component is rendered in a different component tree, connect HoC can't access the redux store via context.
Read more >Creating a centralized modal in React with Redux
This tutorial explains how to build a simple, centralized modal component using React and Redux. If you don't want to follow the tutorial, ......
Read more >Creating a Modal Component: The Redux Way | by Esther Falayi
In App. js , import the modal actions and connect the component to the redux store.
Read more >Your next React Modal with your own "useModal" Hook ...
Hi there everyone, this is a quick review about how to use Modals Components in your React project combining Hooks, Context, and Portals....
Read more >Form - Ant Design
High performance Form component with data scope management. Including data collection, verification, and styles.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That’s because your root component doesn’t include your
Connect(foo)
component.You know,the reason of theConnect
component ofreact-redux
can readstore
due to thecontext
API.But if you put yourConnect(foo)
component into a container which not under the root component.TheConnect(foo)
component can’ read thestore
bycontext
API because yourProvider
component under the root component but modal is appended another container(e.g.body
).So,just like the error says,you can wrap your component with the
Provider
component or pass thestore
as a prop to the component.e.g.
<Modal><Foo store={this.context.store} /></Modal>
or<Modal><Provider store={this.context.store}><Foo /></Provider></Modal>
This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.