Is it recommended in React component to own other objects ? Is there some disadvantage of doing so ? I see it is done here
and here is my example:
import React, {Component} from 'react';
import Utility from './Utility';
export default class MyComponent extends Component {
static defaultProps = {
message: 'Hello',
name: 'John!'
};
constructor(props) {
super(props);
this.utility = new Utility();
}
render() {
return (
<h1>{this.props.message}, {this.props.name} {this.utility.getText()}</h1>
);
}
}
Utility would be some class providing more functionality to the component. Most of the examples I've checked don't have this kind of things. If it is fine to use then would it be better to instantiate in the constructor or in mount function ?