/** * @author oldj * @blog http://oldj.net */ 'use strict'; import React from 'react'; import Editor from './editor'; import classnames from 'classnames'; import './content.less'; export default class Content extends React.Component { constructor(props) { super(props); this.codemirror = null; this.state = { is_loading: this.props.current.is_loading, code: this.props.current.content || '' }; this._t = null; SH_event.on('loading', (host) => { if (host === this.props.current) { this.setState({ is_loading: true }); } }); SH_event.on('loading_done', (host, data) => { if (host === this.props.current) { this.setState({ is_loading: false, code: data.content || '' }); } }); } setValue(v) { this.props.setHostContent(v); } componentWillReceiveProps(next_props) { this.setState({ is_loading: next_props.current.is_loading, code: next_props.current.content || '' }); } render() { let {current} = this.props; return (
loading...
{this.props.current.error}
); } }