Skip to content

Commit f459409

Browse files
committed
change string refs to create refs
1 parent 0836b6c commit f459409

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/GoogleApiComponent.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ export const wrapper = input => WrappedComponent => {
5151
google: null,
5252
options: options
5353
};
54+
55+
this.mapRef=React.createRef();
5456
}
5557

5658
componentWillReceiveProps(props) {
@@ -120,7 +122,7 @@ export const wrapper = input => WrappedComponent => {
120122
return (
121123
<div>
122124
<WrappedComponent {...props} />
123-
<div ref="map" />
125+
<div ref={this.mapRef} />
124126
</div>
125127
);
126128
}

src/index.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ export class Map extends React.Component {
6565
lng: this.props.initialCenter.lng
6666
}
6767
};
68+
69+
this.mapRef=React.createRef();
6870
}
6971

7072
componentDidMount() {
@@ -130,7 +132,7 @@ export class Map extends React.Component {
130132
const {google} = this.props;
131133
const maps = google.maps;
132134

133-
const mapRef = this.refs.map;
135+
const mapRef = this.mapRef.current;
134136
const node = ReactDOM.findDOMNode(mapRef);
135137
const curr = this.state.currentLocation;
136138
const center = new maps.LatLng(curr.lat, curr.lng);
@@ -257,7 +259,7 @@ export class Map extends React.Component {
257259

258260
return (
259261
<div style={containerStyles} className={this.props.className}>
260-
<div style={style} ref="map">
262+
<div style={style} ref={this.mapRef}>
261263
Loading map...
262264
</div>
263265
{this.renderChildren()}

0 commit comments

Comments
 (0)