Reputation: 23801
I just got started with reapp. I simply created an app. Once the app was created, I modified the default home.jsx as shown:
import { Reapp, React } from 'reapp-kit';
class Home extends React.Component {
render() {
return (
<div className='map'></div>
);
}
getDefaultProps() {
return {
initialZoom: 8,
mapCenterLat: 43.6425569,
mapCenterLng: -79.4073126,
};
}
componentDidMount() {
console.log('Dom node is ',this.getDomNode());
}
}
export default Reapp(Home);
Now the issue is the this.getDomNode
which returns the error
Uncaught TypeError: undefined is not a function
Does anyone have any idea what might be wrong ??
Upvotes: 1
Views: 2458
Reputation: 8358
Those who are looking for the updated answer for the latest React, here it goes.
React findDOMNode API is been moved into a react-dom
package. You can find the reference here.
So use,
import ReactDOM from "react-dom";
ReactDOM.findDOMNode(component)
to get the element.
Thank you.
Upvotes: 1
Reputation: 77482
You should use React.findDOMNode(this)
instead of getDomNode
,
class Home extends React.Component {
render() {
return (
<div className='map'></div>
);
}
componentDidMount() {
console.log('Dom node is ', React.findDOMNode(this));
}
}
Upvotes: 2
Reputation: 36418
You should use React.findDOMNode(this)
instead of this.getDOMNode()
, which is deprecated in 0.13.0 and isn't available on classes that extend React.Component
.
Upvotes: 7