I\'m trying to get Quill to work on my React app but depending on my webpack config it throws two errors:
Uncaught SyntaxError: Unexpected token import
Your question helped me figure out how to get Quill working in a React app, so thank you for that!
The "React is not defined" error may have nothing to do with Quill.
Possible solution here: Uncaught ReferenceError: React is not defined
For what it's worth, here is how I imported Quill into a React component.
Note this is using Quill in a React app, and not using the react-quill npm package.
import React from 'react';
// import 'quill/dist/quill.core.css';
import 'quill/dist/quill.snow.css';
import Quill from 'quill/core';
import Toolbar from 'quill/modules/toolbar';
import Snow from 'quill/themes/snow'; //snow works, but need to import and register formats, and replace icons...
import Bold from 'quill/formats/bold';
import Italic from 'quill/formats/italic';
import Header from 'quill/formats/header';
import Underline from 'quill/formats/underline';
import Link from 'quill/formats/link';
import List, { ListItem } from 'quill/formats/list';
import Icons from 'quill/ui/icons';
export default class QuillEditor extends React.Component {
componentDidMount() {
Quill.register({
'modules/toolbar': Toolbar,
'themes/snow': Snow,
'formats/bold': Bold,
'formats/italic': Italic,
'formats/header': Header,
'formats/underline': Underline,
'formats/link': Link,
'formats/list': List,
'formats/list/item': ListItem,
'ui/icons': Icons
});
var icons = Quill.import('ui/icons');
icons['bold'] = '';
icons['italic'] = '';
icons['underline'] = '';
icons['link'] = '';
icons['clean'] = '';
var quill = new Quill('#editor', {
theme: 'snow', //this needs to come after the above, which registers Snow...
placeholder: "Write something awesome..."
});
} //componentDidMount
render() {
return (
{/* */}
Hello World!
Some initial bold text
)
}
}