Reputation: 1466
Note, before reading I have already looked at the following:
Could not find "store" in either the context or props of "Connect(App)" In an react-redux app
Also, I followed the tutorial shown here: https://www.youtube.com/watch?v=9mlwjZL3Fmw
The major difference is that I used create-react-native-app
to initialize my project where the video creator does not.
I want to know if it's possible to get the connect to recognize all the components while keeping the App component in App.js
as a js const.
The previous solutions offered work when I switch to using a javascript class instead:
class App extends React.Component {
etc..
The code is available here: https://github.com/qxh5696/first-react-native-app
I'd like to find the root cause as to why the "store" is not being recognized. Call it stubbornness but I am curious to know if anyone has found a solution to this problem.
Upvotes: 1
Views: 740
Reputation: 76
import
import {connect} from "react-redux";
instead of
import connect from "react-redux/es/connect/connect";
Upvotes: 0
Reputation: 15483
The root cause of the error is when we put together a react-redux application we should expect to see a structure where at the top we have the Provider
tag which has an instance of a redux store.
That Provider
tag then renders your parent component, lets call it the App
component which in turn renders every other component inside the application.
Here is the key part, when we wrap a component with the connect()
function, that connect()
function expects to see some parent component within the hierarchy that has the Provider
tag.
So the instance you put the connect()
function in there, it will look up the hierarchy and try to find the Provider
.
Thats what you want to have happen, but in your test environment that flow is breaking down.
Upvotes: 1