Error in GoogleMapReact with Next.js: TypeError occurs when trying to read properties of undefined, specifically 'getChildren'

Currently, I am working on a basic nextjs application using the google-map-react component and nextjs. However, I keep encountering an error whenever I try to utilize the component.

The error message reads as follows: "TypeError: can't access property "getChildren", n.props.dispatcher is undefined"

I'm unsure about what steps to take next as it appears to be related to the version of reactapp that I am currently using.

    import React from 'react';
    import GoogleMapReact from 'google-map-react';

    export default function Map({ coords }: { coords: { lat: number; lng: number } }) {

    return (
        <>
        <div className='w-full h-4/5'>
            <GoogleMapReact
                bootstrapURLkeys={{ key: process.env.REACT_APP_GOOGLE_MAPS_API_KEY }}
                defaultCenter={coords}
                center={coords}
                defaultZoom={14}
                margin={[50, 50, 50, 50]}
            >
            </GoogleMapReact>
        </div>
        <div>
            dede
        </div>
        </>
    )
}

PACKAGE.JSON

{
  "name": "travelcompagnon",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "next": "12.1.6",
    "react": "18.1.0",
    "react-dom": "18.1.0"
  },
  "devDependencies": {
    "@react-google-maps/api": "^2.10.2",
    "@types/node": "17.0.31",
    "@types/react": "18.0.9",
    "@types/react-dom": "18.0.3",
    "autoprefixer": "^10.4.7",
    "axios": "^0.27.2",
    "dotenv": "^16.0.0",
    "eslint": "8.15.0",
    "eslint-config-next": "12.1.6",
    "google-map-react": "^2.1.10",
    "postcss-import": "^14.1.0",
    "tailwindcss": "^3.0.24",
    "typescript": "4.6.4"
  }
}

Answer №1

To stop ReactStrictMode, you should turn off the reactStrictMode setting and then relaunch your Next.js application server.

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: false,
}

module.exports = nextConfig

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What causes the webpage to reset its scroll position when a component rerenders?

In the process of creating my personal blog with Next.js, I retrieve posts from my API using a page query for pagination. Then, I iterate through the items in this manner: let content = ( <ul> {props.posts.map((post) => { return &l ...

Troubleshooting 'Warning: Prop `id` did not match` in react-select

Having an issue with a web app built using ReactJs and NextJs. I implemented the react-select component in a functional component, but now I'm getting this warning in the console: Warning: Prop id did not match. Server: "react-select-7 ...

Tips for Fixing Error: "We received a visitor for node type TSSatisfiesExpression that is not recognized as a valid type."

There seems to be an issue with Babel unable to compile my Storybook code. I'm working on setting up a boilerplate with Storybook and Next.js I've searched for a solution to this problem but couldn't find one. Any help would be greatly app ...

I'm having trouble getting my next.js modules to load and I'm not sure who to reach out to for

When I attempt to console the npx create-next-app my-app command, I encounter issues loading modules. An error message similar to this image appears when I try to run it, as shown in this other image here. I had hoped for a successful project launch with ...

An object in typescript has the potential to be undefined

Just starting out with Typescript and hitting a snag. Can't seem to resolve this error and struggling to find the right solution useAudio.tsx import { useEffect, useRef } from 'react'; type Options = { volume: number; playbackRate: num ...

Tips for creating a default route with parameters in Angular Component Router?

I am trying to set a default route in my sub-component (using useAsDefault: true) and have parameters automatically passed to it, but I can't seem to find any information on how to accomplish this in the documentation. I have a parent component with t ...

Warning: Potential spacing issues when dynamically adjusting Material UI Grid using Typescript

When working with Typescript, I encountered an error related to spacing values: TS2322: Type 'number' is not assignable to type 'boolean | 7 | 2 | 10 | 1 | 3 | 4 | 5 | 6 | 8 | "auto" | 9 | 11 | 12'. No lint errors found Version: typesc ...

Using ngIf for binding

Trying to bind values based on conditions specified in *ngIf. However, when using the && operator within *ngIf, it seems to be behaving mysteriously. Sample Code: <div *ngIf="days.sunday == true"> <p class="circle ml-3" ...

When attempting to declare a functional component in React utilizing styled-components in TypeScript, an error is encountered stating "No overload matches this call."

Playground https://codesandbox.io/s/typescript-type-checking-question-0b42t Sample Code type BadgeTypes = { success: string; secondary: string; alert: string; text: string; }; type Theme = { fonts?: object; borderRadius: string; primary?: o ...

Is it possible to transform a Next.js application into a React Native mobile app?

I've been really enjoying using Next.js in combination with tailwindcss for my web app. Now I want to expand its reach by creating iOS and Android versions, but I'm not sure if I can simply convert my existing Next.js project into a mobile app or ...

Using Typescript to mute audio elements within HTML documents

I have a scenario where I want to mute audio that automatically plays when the screen loads. In order to achieve this, I am attempting to add a button that can toggle the audio mute functionality using Typescript within an Angular4 application. The code sn ...

An exploration of distributing union types within conditional type arrays in TypeScript

One interesting challenge I am facing involves a conditional type that utilizes a generic type T in order to determine an Array<T> type. For example: type X<T> = T extends string ? Array<T> : never; The issue arises when I input a union ...

"Mastering the art of debouncing in Angular using

I am facing an issue where, during a slow internet connection, users can press the save button multiple times resulting in saving multiple sets of data. This problem doesn't occur when working locally, but it does happen on our staging environment. E ...

How to Retrieve a Global Variable in an Angular Template

Is there a way to access a global variable from an Angular template? let unableToAccess = false; @Component({ selector: 'app-payment', templateUrl: './buy.component.html', styleUrls: ['./buy.component.scss'] }) export ...

Converting JSON to TypeScript in an Angular project

Within my Angular project, I have an HTTP service that communicates with a web API to retrieve JSON data. However, there is a discrepancy in the naming convention between the key in the JSON response (e.g., "Property" in uppercase) and the corresponding pr ...

Sharing the state of React Context between components is causing issues

After extensively using Redux, I decided to explore the new Context API. Successfully implemented it with a single component/page in NextJs. However, faced an issue where the state is not shared across different pages/components. store.js import React, ...

The local types package cannot be built by react-scripts even though tsc has successfully completed the process

I have developed an application with a TypeScript frontend and backend. To streamline the process, I decided to create a shared types module that contains all the necessary types for both components in one centralized location. Rather than going through th ...

Issue with Next.js: Callback function not being executed upon form submission

Within my Next.js module, I have a form that is coded in the following manner: <form onSubmit = {() => { async() => await requestCertificate(id) .then(async resp => await resp.json()) .then(data => console.log(data)) .catch(err => console ...

Typescript tutorial: Implementing a 'lambda function call' for external method

The Issue Just recently diving into Typescript, I discovered that lambda functions are utilized to adjust the value of this. However, I find myself stuck on how to pass my view model's this into a function that calls another method that hasn't b ...

Is there a method in AngularJS to compel TypeScript to generate functions instead of variables with IIFE during the compilation process with gulp-uglify?

My AngularJS controller looks like this: ArticleController.prototype = Object.create(BaseController.prototype); /* @ngInject */ function ArticleController (CommunicationService){ //Some code unrelated to the issue } I minified it using gulp: retur ...