Update redux store from onRouteUpdate? #26874
-
Hi, how do I update a redux store from within Gatsby Browser API? I need to update a TOGGLE_MENU action from within onRouteUpdate to close a mobile menu. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
Not sure it's possible within |
Beta Was this translation helpful? Give feedback.
-
Thanks @herecydev. I'm trying to avoid using clicks because I want to ensure the new page has loaded behind the menu before it closes. How would you use |
Beta Was this translation helpful? Give feedback.
-
Use wrapPageElement, this will give you access to each page's props. I'm guessing you would want to inspect the |
Beta Was this translation helpful? Give feedback.
-
As @herecydev correctly said you'll want to use the One more thing to note/a tip: When you also keep the menu in |
Beta Was this translation helpful? Give feedback.
-
@LekoArts So I need both I'm using gatsby-plugin-react-redux which already creates a provider. Does it matter if I have 2 providers or will I need to remove this plugin? Heres how I currently have it setup
|
Beta Was this translation helpful? Give feedback.
-
If you're using |
Beta Was this translation helpful? Give feedback.
Use wrapPageElement, this will give you access to each page's props. I'm guessing you would want to inspect the
path
prop and then dispatch an appropriate action into your redux.