import { isEqual } from 'lodash';
import { Component, PropTypes } from 'react';

const propTypes = {
    template: PropTypes.string.isRequired,
};

export default class Soy extends Component {
    shouldComponentUpdate(nextProps) {
        return !isEqual(this.props, nextProps);
    }

    render() {
        const soy = {
            __html: this.props.template(this.props),
        };
        return <div className="soy-container" dangerouslySetInnerHTML={soy}></div>;
    }
}

Soy.propTypes = propTypes;
