Reason is, you defined that function as static, directly using this keyword it will not be accessible.
As per DOC:
Static method calls are made directly on the class and are not callable
on instances of the class.
Static methods are not directly accessible using the this keyword from
non-static methods. You need to call them using the class name:
CLASSNAME.STATIC_METHOD_NAME() or by calling the method as a property
of the constructor: this.constructor.STATIC_METHOD_NAME().
In order to call a static method within another static method of the
same class, you can use the this keyword.
In you case i think you don't need a static method, instead of defining that as a static, write it like this:
class Content extends React.Component {
getValue() {
return "<div> Hello </div>";
}
render() {
let value = this.getValue();
return <div dangerouslySetInnerHTML={{__html: value}} />
}
}
ReactDOM.render(<Content/>, document.getElementById('app'))
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id='app'/>
Update:
You changed the original question, if you defined another class and want to call a function of that then you need to define that as static.
class Content extends React.Component {
render() {
let value = App.getValue();
return <div dangerouslySetInnerHTML={{__html: value}} />
}
}
class App {
static getValue() {
return "<div> Hello </div>";
}
}
ReactDOM.render(<Content/>, document.getElementById('app'))
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
<div id='app'/>