//License CC0 1.0: https://creativecommons.org/publicdomain/zero/1.0/
class Deferred extends React.Component {
constructor(props) {
super(props);
this.state = {
value: ''
};
}
componentDidMount() {
this.props.promise.then(value => {
this.setState({value});
});
}
render() {
const then = this.props.then || (value => {value});
return then(this.state.value);
}
}
//...
// example
{v}} />