Cannot read property 'Provider' of undefined. BaseContext from `@reach/router` is undefined.
See original GitHub issueDescription
BaseContext
is undefined here.
Also, it looks like @reach/router
doesn’t export BaseContext 🤔. Ideally gatsby
shouldnt’ be relying on this import, if its not actually exported from @reach/router
.
NOTE: This issue goes away, if I fix the BaseContext
by copying over the snippet to re-create it from here and then patching the production-app.js
file inside cache-dir
.
const RouteHandler = props => (
<BaseContext.Provider
value={{
baseuri: `/`,
basepath: `/`,
}}
>
<PageRenderer {...props} />
</BaseContext.Provider>
)
Steps to reproduce
Issue arises especially when I use docker to create a docker image of the source code, and then build the gatsby image, copying the public
directory and then use tools like serve
to host the static files. This is NOT reproducible on gatsby build
or gatsby develop
, which makes it even more difficult to debug, on why this issue is happening. I’m unfortunately not able to provide more information due to lack thereof.
Expected Behaviour
Gatsby should handle the BaseContext
being undefined error, more gracefully.
Environment
System: OS: macOS 10.15.5 CPU: (12) x64 Intel® Core™ i7-9750H CPU @ 2.60GHz Shell: 5.7.1 - /bin/zsh Binaries: Node: 12.18.3 - ~/n/bin/node Yarn: 1.22.4 - ~/.yarn/bin/yarn npm: 6.14.7 - /usr/local/bin/npm Languages: Python: 2.7.16 - /usr/bin/python Browsers: Edge: 85.0.564.44 Safari: 13.1.1 npmPackages: gatsby: ^2.24.53 => 2.24.54 gatsby-link: ^2.4.13 => 2.4.13 gatsby-plugin-catch-links: ^2.3.5 => 2.3.11 gatsby-plugin-emotion: ^4.3.2 => 4.3.10 gatsby-plugin-gtag: ^1.0.12 => 1.0.13 gatsby-plugin-layout: ^1.3.10 => 1.3.10 gatsby-plugin-manifest: ^2.2.33 => 2.4.28 gatsby-plugin-mdx: ^1.0.61 => 1.2.38 gatsby-plugin-nprogress: ^2.3.2 => 2.3.10 gatsby-plugin-offline: ^3.2.11 => 3.2.27 gatsby-plugin-react-helmet: ^3.1.18 => 3.3.10 gatsby-plugin-remove-serviceworker: ^1.0.0 => 1.0.0 gatsby-plugin-remove-trailing-slashes: ^2.3.5 => 2.3.11 gatsby-plugin-sitemap: ^2.2.24 => 2.4.12 gatsby-remark-autolink-headers: ^2.3.5 => 2.3.12 gatsby-remark-copy-linked-files: ^2.1.33 => 2.3.14 gatsby-source-filesystem: ^2.3.27 => 2.3.28 gatsby-transformer-remark: ^2.8.32 => 2.8.33
Issue Analytics
- State:
- Created 3 years ago
- Comments:21 (8 by maintainers)
Top GitHub Comments
Hi! It’s over two years now and I also still have this bug. Is there any way we can help?
Hello , I am facing same exact issue! any fix or help , please ?