all files / lib/resources/ html-resource.jsx

100% Statements 13/13
50% Branches 1/2
100% Functions 4/4
100% Lines 13/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                                    12×                            
'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;