timlrx / tailwind-nextjs-starter-blog

This is a Next.js, Tailwind CSS blogging starter template. Comes out of the box configured with the latest technologies to make technical writing a breeze. Easily configurable and customizable. Perfect as a replacement to existing Jekyll and Hugo individual blogs.
https://tailwind-nextjs-starter-blog.vercel.app/
MIT License
8.53k stars 1.97k forks source link

Using redux toolkit store with an mdx component #60

Closed cordobadigitalmedia closed 3 years ago

cordobadigitalmedia commented 3 years ago

Hi I using your template and it's working really great. Thanks so much However, I've hit a wall related to make a redux toolkit store available to a component that's placed inside an mdx file. I have wrapped my whole app with the store provider as usual but on the page that loads the mdx file that has a component that needs to load data from the store, I get this error

Error: Could not find "store" in the context of "Connect(NameofComponent)". Either wrap the root component in a <Provider>, or pass a custom React context provider to <Provider> and the corresponding React context consumer to Connect(NameofComponent) in connect options.

Do you have any suggestions how I would make the store available to a component inside an mdx file. I've had a similar issue with trying to load data asynchronously in an MDX component and I've had to use a different strategy that was not too convenient.

timlrx commented 3 years ago

Hi, working with nextjs and redux is a little tricky as it depends on whether you are working on the client or server state. It seems that your setup is wrong as it is not able to locate the store. Nexjs documentation has an example on it.

This is more of a nextjs / redux integration question and not related to the template so it's better to direct it to the nextjs repo.