Avatar of Dinesh Bali
Dinesh Bali asked on

Cannot read properties of undefined (reading 'props')

Hi,


In my react app. I am getting below error from the following code.

This code is taken from:

https://www.npmjs.com/package/google-maps-react


import React from "react";
import { Map, InfoWindow, Marker, GoogleApiWrapper } from 'google-maps-react';

const Googlemap = () => {
        return (
                <Map google={this.props.google} zoom={14}>
                        <Marker onClick={this.onMarkerClick}
                                name={'Current location'} />
                        <InfoWindow onClose={this.onInfoWindowClose}>
                                <div>
                                        <h1>{this.state.selectedPlace.name}</h1>

                                </div>
                        </InfoWindow>
                </Map>
        );
}
export default GoogleApiWrapper({
        apiKey: ("My key")
})(Googlemap)

Open in new window


Error:




Please advise.


Kind Regards,





ReactProgramming Languages-OtherHTMLWeb DevelopmentScripting Languages

Avatar of undefined
Last Comment
Scott Fell

8/22/2022 - Mon
Scott Fell

I have not dove into react very much, but I will try and help.

From your example, I found the original here GitHub - fullstackreact/google-maps-react: Companion code to the "How to Write a Google Maps React Component" Tutorial 

What I think I am seeing in your error is 'props' is not defined.

Do you have code that defines that?

Also, is your google api key activated?  and set for your ip? That will also throw an error, but that will be a different error I believe. 
ASKER
Dinesh Bali

Thanks for your reply.
I am not sure what props I should pass.
Key is activated.
Used the same code as in example given at url:
https://www.npmjs.com/package/google-maps-react 

Please advise.

ASKER CERTIFIED SOLUTION
Scott Fell

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck