jkhaui
1/4/2019 - 1:58 PM

index.js

import React, { Component } from 'react';
import 'whatwg-fetch';
import MediumEditor from 'medium-editor';
import Citation from './citation.js';

class BookCitation extends Component {
    
    constructor( props ) {
        super( props )
        this.state = {
            editor : null,
        }
        this.editorContainer = React.createRef()
    }

    componentDidMount() {
        this.setState({ editor : new MediumEditor( this.editorContainer.current ) })
    }

    render() {
        return(
                <Citation 
                    editor={ this.state.editor } 
                    bookNotFound={ 
                        book => document.getElementById("editor").innerHTML = 
                        'No book was found. Try refining the title or author names.' 
                    }
                >
                    <div id="editor" ref={ this.editorContainer } />
                </Citation>
        )
    }
}

export default BookCitation;