mirror of
https://github.com/Kong/insomnia
synced 2024-11-12 17:26:32 +00:00
44 lines
760 B
JavaScript
44 lines
760 B
JavaScript
// @flow
|
|
import React from 'react';
|
|
|
|
class RenderedText extends React.PureComponent {
|
|
props: {
|
|
component: string,
|
|
children: string,
|
|
render: Function,
|
|
props?: Object
|
|
};
|
|
|
|
state: {
|
|
renderedText: string
|
|
};
|
|
|
|
constructor (props: any) {
|
|
super(props);
|
|
this.state = {
|
|
renderedText: ''
|
|
};
|
|
}
|
|
|
|
async _render () {
|
|
const {render, children} = this.props;
|
|
const renderedText = await render(children);
|
|
this.setState({renderedText});
|
|
}
|
|
|
|
componentDidMount () {
|
|
this._render();
|
|
}
|
|
|
|
componentDidUpdate () {
|
|
this._render();
|
|
}
|
|
|
|
render () {
|
|
const {component, props} = this.props;
|
|
return React.createElement(component, props || {}, this.state.renderedText);
|
|
}
|
|
}
|
|
|
|
export default RenderedText;
|