Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with context #79

Closed
gyzerok opened this issue Aug 30, 2015 · 8 comments
Closed

Problems with context #79

gyzerok opened this issue Aug 30, 2015 · 8 comments

Comments

@gyzerok
Copy link

gyzerok commented Aug 30, 2015

I'm trying to build my own components on top of react-redux. I'm stuck with the following error:

Uncaught Error: Invariant Violation: Could not find "store" in either the context or props of "Connect(SmartComponent(App))". Either wrap the root component in a <Provider>, or explicitly pass "store" as a prop to "Connect(SmartComponent(App))".

My components need to have their own childContext. Mb I need somehow to merge childContext of my components with one from react-redux?

@gnoff
Copy link
Contributor

gnoff commented Sep 1, 2015

Are you using a <Provider> higher up in your component tree than the component that you are using connect on?

@gaearon
Copy link
Contributor

gaearon commented Sep 2, 2015

There is nothing we can help you with unless you provide a full example.
Please reopen when there is something we can run and test.

Mb I need somehow to merge childContext of my components with one from react-redux?

No, React merges context.

@gaearon gaearon closed this as completed Sep 2, 2015
@gyzerok
Copy link
Author

gyzerok commented Sep 2, 2015

@gaearon sorry for not closing an issue, I've already find the solution.

@gaearon
Copy link
Contributor

gaearon commented Sep 2, 2015

What was it?

@gyzerok
Copy link
Author

gyzerok commented Sep 2, 2015

const router = (
  <Router history={history}>
    // routes here
  </Router>
);

<Provider>
  {() => router}
</Provider>

Was not obvious for me that Router component itself have to be declared in the function body.

@gaearon
Copy link
Contributor

gaearon commented Sep 2, 2015

@gyzerok
Copy link
Author

gyzerok commented Sep 3, 2015

@gaearon I guess here is another problem. I thougt that if I place router variable as and return value from function inside Provider it would be similar to put tag inside Provider. I think its all about how JSX work. Dont know how to describe it better. Hope you can :)

@gaearon
Copy link
Contributor

gaearon commented Sep 3, 2015

Okay. I think we'll just wait for React 0.14 because the problem will go away with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants