michelson / dante2

A complete rewrite of dante editor in draft-js
https://michelson.github.io/dante2/
Other
912 stars 121 forks source link

Content initialization via useState is not working with latest react #198

Closed avifatal closed 4 years ago

avifatal commented 4 years ago

Hi, When I try to load the content via useState it is not appearing: https://stackblitz.com/edit/react-prwej4

But, if I do it directly, it does work: https://stackblitz.com/edit/react-5jpjqs?file=index.js

Any idea how I can do it with useState?

Thanks

michelson commented 4 years ago

Hi @avifatal , thanks for report this,

I've deprecated this on the current version, but thinking twice its better to have this feature than not. Be aware that if you mutate the state on content the editor will reinitialize the content but you will loose the cursor selection. in other works if you intent to make editor uncontrolled mutating the content value you will get a nasty behavior. use it only for initialize content

I've deployed version rc23 , here is the example https://michelson.github.io/dante2/#/src-content-update.

I will close this now , but if you get in to troubles please reopen this issue

avifatal commented 4 years ago

Thanks. Can you please try and correct my sample here: https://stackblitz.com/edit/react-prwej4 ?