Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Best way to import and use Delta? #33

Closed
DaltheCow opened this issue Aug 28, 2021 · 1 comment
Closed

Best way to import and use Delta? #33

DaltheCow opened this issue Aug 28, 2021 · 1 comment

Comments

@DaltheCow
Copy link

Hey love the repo! This is a question, not sure how to tackle this problem using hooks and react-quilljs. I'd like this to work:

const { quill, quillRef, Quill } = useQuill({ theme, modules, formats });
var Delta = Quill?.import("delta");
const [change, setChange] = React.useState(new Delta());

My problem is that Delta doesn't exist when the initial value is set in the useState. I'd rather not instantiate it as undefined if I can avoid, typescript will make me treat it as if it can be undefined everywhere, but I'm not sure what the best work around would be.

Right now my work around which seems fine is just importing Delta like this:
import Delta from "quill-delta";

@gtgalone
Copy link
Owner

@DaltheCow Thank you for using!

I think quill-delta is a totally separated package with quill.

So you don't have to import delta like this var Delta = Quill?.import("delta");.

If you want to set initial value with delta, you can refer https://github.com/gtgalone/react-quilljs#with-initial-value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants