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:



User generated image


Please advise.


Kind Regards,





ReactProgramming Languages-OtherHTMLWeb DevelopmentScripting Languages

Avatar of undefined
Last Comment
Scott Fell
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

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?
User generated image
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. 
Avatar of Dinesh Bali
Dinesh Bali

ASKER

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
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Web Development
Web Development

Web development includes all aspects of presenting content on intranets and the Internet, including delivery development, protocols, languages and standards, server software, browser clients, databases and multimedia generation.

78K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo