all files / resources/ html-resource.jsx

61.54% Statements 8/13
0% Branches 0/2
0% Functions 0/4
61.54% Lines 8/13
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45                                                                         
'use strict';
 
import React from 'react';
import Bluebird from 'bluebird';
import axios from 'axios';
import { vastBaseStyle } from '../helpers/styles';
 
class HtmlResource extends React.Component {
 
  constructor(props) {
    super(props);
 
    this.state = {
      html: null,
      htmlSrc: this.props.resource.getValue(),
    };
  }
 
  componentDidMount() {
    Bluebird.resolve(axios.get(this.state.htmlSrc)).then((htmlStr) => {
      this.setState({
        html: { __html: htmlStr.data },
      });
    });
  }
 
  render() {
    return (
      <div
        style={vastBaseStyle}
        dangerouslySetInnerHTML={this.state.html}
      >
      </div>
    );
  }
 
}
 
HtmlResource.propTypes = {
  resource: React.PropTypes.object.isRequired,
  request: React.PropTypes.object,
};
 
export default HtmlResource;