Marker not showing in Next/React App | @react-google-maps/api

vatana7 - Aug 10 '22 - - Dev Community

Fixing Marker component

Npm Package: @react-google-maps/api

I was working with React Google Map Api today and I found myself figuring and scratching my head on why wasn't the Marker showing up on the app? I configured literally everything on the file that I was working on and that included: checking Google Map API, rechecking all the code, rechecking typos, rechecking imports.

All that but it still doesn't work. And you know what's worse? When I try to console.log(), the Marker component just randomly show up and it made me question myself and the code that I was writing.

Anyway, if your React/NextJS project has React version of 18, it turns out you have to remove StrictMode from your project in order for the Marker component to show up.

Removing StrictMode from ReactJS

ReactDOM.render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
  document.getElementById('root')
);
Enter fullscreen mode Exit fullscreen mode

to

ReactDOM.render(
    <App />
  document.getElementById('root')
);
Enter fullscreen mode Exit fullscreen mode

Removing StrictMode from NextJS

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: false
}
Enter fullscreen mode Exit fullscreen mode

After that your code should work and the Marker component should appear!

. . . . . . . . . . . .
Terabox Video Player