Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mapCenter warning #392

Open
brightsider opened this issue Nov 5, 2019 · 3 comments
Open

mapCenter warning #392

brightsider opened this issue Nov 5, 2019 · 3 comments

Comments

@brightsider
Copy link

@brightsider brightsider commented Nov 5, 2019

How to fix this warning?
React does not recognize the mapCenterprop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercasemapcenter instead. If you accidentally passed it from a parent component, remove it from the DOM element.

@SimantoR
Copy link

@SimantoR SimantoR commented Dec 4, 2019

Can you provide a sample code? That should help understand what's triggering the warning

@alamorre
Copy link

@alamorre alamorre commented Feb 12, 2020

<Map
    zoom={14}
    google={this.props.google}  
    initialCenter={{ lat: this.props.latitude, lng: this.props.longitude }}
    center={{ lat: this.props.latitude, lng: this.props.longitude }}
>
    {/*Standard JSX*/}
</Map>

I get the same issue. "The unknown-prop warning will fire if you attempt to render a DOM element with a prop that is not recognized by React as a legal DOM attribute/property."

They recommend to change it to lowercase to make it a legal name again. If you change mapCenter to mapcenter you should be good. But user can't do much about it.

People (like myself) need it to update the center when onDragend occurs.

@vikaskulkarni
Copy link

@vikaskulkarni vikaskulkarni commented Feb 25, 2020

Even though I was not using the center attribute, I was still get this warning when I wrapped one Map component inside another (the top one was not visible though, it was just to get the props).

Did you try setting the center instead of passing it as an attribute?

let currentPosition = {
    lat: position.coords.latitude,
    lng: position.coords.longitude
};
map.setCenter(currentPosition);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.