question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Element ref was specified as a string (map) but no owner was set

See original GitHub issue

Hi, I’m getting an error when I attempt to load the Map component.

Uncaught Error: Element ref was specified as a string (map) but no owner was set. This could happen for one of the following reasons:

  1. You may be adding a ref to a functional component
  2. You may be adding a ref to a component that was not created inside a component’s render method
  3. You have multiple copies of React loaded See https://fb.me/react-refs-must-have-owner for more information. at invariant (VM56119 invariant.js:42) at coerceRef (VM56126 react-dom.development.js:7350) at createChild (VM56126 react-dom.development.js:7555) at reconcileChildrenArray (VM56126 react-dom.development.js:7805) at reconcileChildFibers (VM56126 react-dom.development.js:8121) at reconcileChildrenAtExpirationTime (VM56126 react-dom.development.js:8240) at reconcileChildren (VM56126 react-dom.development.js:8231) at updateHostComponent (VM56126 react-dom.development.js:8539) at beginWork (VM56126 react-dom.development.js:8986) at performUnitOfWork (VM56126 react-dom.development.js:11814)

Below is my dependency list. I attempted to degrade react to ^15.0.0, but other packages broke.

“dependencies”: { “chart.js”: “^2.7.2”, “google-maps-react”: “^2.0.0”, “highcharts”: “^6.1.0”, “moment”: “^2.22.1”, “prop-types”: “^15.6.1”, “react”: “^16.3.2”, “react-chartjs-2”: “^2.7.0”, “react-dates”: “^16.6.1”, “react-dom”: “^16.3.2”, “react-highcharts”: “^16.0.2”, “react-router-dom”: “^4.2.2”, “react-vis”: “^1.9.2” }, “devDependencies”: { “babel-core”: “^6.26.0”, “babel-loader”: “^7.1.4”, “babel-preset-env”: “^1.6.1”, “babel-preset-react”: “^6.24.1”, “css-loader”: “^0.28.11”, “eslint”: “^4.19.1”, “eslint-plugin-react”: “^7.7.0”, “file-loader”: “^1.1.11”, “html-webpack-plugin”: “^3.2.0”, “node-sass”: “^4.8.3”, “sass-loader”: “^7.0.1”, “style-loader”: “^0.21.0”, “url-loader”: “^1.0.1”, “webpack”: “^4.6.0”, “webpack-cli”: “^2.0.14”, “webpack-dev-server”: “^3.1.3” }

and here’s my Map component:

import React, { Component } from 'react';
import { GoogleApiWrapper, Map as GoogleMap } from 'google-maps-react';

class Map extends Component {
    render() {
        const style = {
            width: '100vw',
            height: '100vh'
        };
        return (
            <div style={style}>
                <GoogleMap 
                    google={this.props.google}
                />
            </div>
        );
    }
}

export default GoogleApiWrapper({
    apiKey: "MY_API_KEY"
})(Map);

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:6
  • Comments:8

github_iconTop GitHub Comments

1reaction
Hi-Rubecommented, Feb 7, 2019

@AtlasMaxima what does it mean to install in a “client” folder?

use like this:

import React, { Component } from 'react';
import { GoogleApiWrapper, Map as GoogleMap } from 'google-maps-react';

class Map extends Component {
    render() {
        const style = {
            width: '100vw',
            height: '100vh'
        };
        return (
            <div style={style}>
                <GoogleMap 
                    google={this.props.google}
                />
            </div>
        );
    }
}

const MapWrapper = GoogleApiWrapper({
    apiKey: "MY_API_KEY"
})(Map);

class ExportMap extends Component{
    render(){
        return (<MapWrapper/>)
    }
}
export default ExportMap;
1reaction
AtlasMaximacommented, Oct 17, 2018

I have react ^16.5.2 and I received this error because I didn’t install npm install --save google-maps-react in the client folder. And I have just installed the package inside of the client folder and GoogleMaps is showing up now.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Element ref was specified as a string (map) but no owner was ...
According to react documentation on version 16.3 changes, the legacy string ref api is deprecated and now you should use the ref callback ......
Read more >
Are you reporting a bug or runtime error? - GitHub
Element ref was specified as a string (value0) but no owner was set. You may have multiple copies of React loaded.
Read more >
Refs Must Have Owner Warning - React
Element ref was specified as a string (myRefName) but no owner was set. You may have multiple copies of React loaded. (details: https://fb.me/react-refs-must- ......
Read more >
Element ref was specified as a string (clickAwayableElement ...
Coding example for the question Element ref was specified as a string (clickAwayableElement) but no owner was set-Reactjs.
Read more >
Refs to Components | React
render #. Not to be confused with the render() function that you define on your component (and which returns a virtual DOM element),...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found