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,
};
}
ponentDidMount() {
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 ??
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,
};
}
ponentDidMount() {
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 ??
Share Improve this question edited Apr 21, 2015 at 22:15 tbodt 17k7 gold badges61 silver badges86 bronze badges asked Apr 21, 2015 at 12:19 iJadeiJade 23.9k58 gold badges160 silver badges250 bronze badges 03 Answers
Reset to default 7You 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
.
You should use React.findDOMNode(this)
instead of getDomNode
,
class Home extends React.Component {
render() {
return (
<div className='map'></div>
);
}
ponentDidMount() {
console.log('Dom node is ', React.findDOMNode(this));
}
}
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(ponent)
to get the element.
Thank you.