DigitalDisaster
DigitalDisaster

Reputation: 507

Accessing redux dispatch from deeply nested components

I'm using react-redux with the components. It passes dispatch as a prop into my top level component, but i'm having trouble accessing it from deeply nested (and some other more complexly mounted) components. What is the best way to access dispatch from any component? Do I need to pass it manually as a prop to every component I'd like to use it in?

Upvotes: 0

Views: 651

Answers (2)

woryzower
woryzower

Reputation: 976

If you don't want to use connect everywhere around you can just explicitly import store and dispatch on it: http://redux.js.org/docs/basics/Store.html

Upvotes: 0

Christopher Chiche
Christopher Chiche

Reputation: 15325

You can use connect on components even if they are bellow some already connected components.

Upvotes: 2

Related Questions