question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Modal.confirm and other global popup component can't set redux HOC Connect as content

See original GitHub issue

Version

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:closed
  • Created 6 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
NE-SmallTowncommented, Jun 1, 2017

That’s because your root component doesn’t include your Connect(foo) component.You know,the reason of the Connect component of react-redux can read store due to the context API.But if you put your Connect(foo) component into a container which not under the root component.The Connect(foo) component can’ read the store by context API because your Provider 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 the store 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>

0reactions
lock[bot]commented, Jun 5, 2018

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found