JustFly1984 / react-google-maps-api

React Google Maps API
MIT License
1.78k stars 437 forks source link

TypeError: (0 , react__WEBPACK_IMPORTED_MODULE_1__.createContext) is not a function with Next.js and React 18 #3369

Open RobinaShaheen opened 1 month ago

RobinaShaheen commented 1 month ago

Issue template

You can donate or became a sponsor https://opencollective.com/react-google-maps-api#category-CONTRIBUTE

If you want to ask question, please ask it in Github Discussions, Spectrum.chat or Slack channel

I am experiencing a TypeError: (0 , react__WEBPACK_IMPORTED_MODULE_1__.createContext) is not a function when using @react-google-maps/api with a Next.js project and React 18.

Please do not post unformatted code into issues, and please do not ask questions. Only real issues, PR's or feature requests are allowed. Minimal reproduction in codesandbox.io is required.

Help wanted

As mentioned in this issue, the author of this project will only accept issues with codesandbox reproduction and PR with solution going forward.

Please provide an explanation of the issue

Your Environment

os: mac/linux/windows/android/ios

node --version

react version

webpack version

@babel version

@react-google-maps/api version

How does it behave?

How should it behave correctly?

Basic implementation of incorrect behavior in codesandbox.com

RobinaShaheen commented 1 month ago

anyone idea to solve this issue

sdkayy commented 1 month ago

Seems this is actually a next issue, and the map being inside of a server component using the Context API, try marking your map component a client component with "use client", just ran into this and found this discussion