import React from 'react'; import ReactDOM from 'react-dom'; import { FormattedMessage } from 'react-intl'; import classNames from 'classnames'; import { Icon } from 'antd'; import EditButton from './EditButton'; export default class Demo extends React.Component { static contextTypes = { intl: React.PropTypes.object, } constructor(props) { super(props); this.state = { codeExpand: false, }; } shouldComponentUpdate(nextProps, nextState) { return (this.state.codeExpand || this.props.expand) !== (nextState.codeExpand || nextProps.expand); } componentDidMount() { const { meta, location } = this.props; if (meta.id === location.hash.slice(1)) { this.anchor.click(); } } handleCodeExapnd = () => { this.setState({ codeExpand: !this.state.codeExpand }); } saveAnchor = (anchor) => { this.anchor = anchor; } render() { const props = this.props; const { meta, src, content, preview, highlightedCode, style, highlightedStyle, expand, } = props; if (!this.liveDemo) { this.liveDemo = meta.iframe ?