fix: document viewer
This commit is contained in:
parent
21895e8ce4
commit
ebbd983a7f
1 changed files with 14 additions and 11 deletions
|
@ -32,21 +32,24 @@ class DocumentViewer extends React.PureComponent<Props, State> {
|
|||
|
||||
componentDidMount() {
|
||||
const { source } = this.props;
|
||||
const stream = source.stream('utf8');
|
||||
|
||||
let data = '';
|
||||
if (source && source.stream) {
|
||||
const stream = source.stream('utf8');
|
||||
|
||||
stream.on('data', chunk => {
|
||||
data += chunk;
|
||||
});
|
||||
let data = '';
|
||||
|
||||
stream.on('end', () => {
|
||||
this.setState({ content: data, loading: false });
|
||||
});
|
||||
stream.on('data', chunk => {
|
||||
data += chunk;
|
||||
});
|
||||
|
||||
stream.on('error', () => {
|
||||
this.setState({ error: true, loading: false });
|
||||
});
|
||||
stream.on('end', () => {
|
||||
this.setState({ content: data, loading: false });
|
||||
});
|
||||
|
||||
stream.on('error', () => {
|
||||
this.setState({ error: true, loading: false });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
renderDocument() {
|
||||
|
|
Loading…
Add table
Reference in a new issue