-
Notifications
You must be signed in to change notification settings - Fork 48
Sys - Editor crashes every time parent setState is called #77
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
Comments
Thank you for reporting it! I will have a look as soon as time allows to identify the issue. |
Dear god, don't use setState please, it is a bad bad practice. 90% of the time you use setState you should probably use ValueNotifier/Stream/Publisher/ChangeNotifier/Bloc instead. The contractual invariant is mathematically stricter and easier to reason with for all those alternatives but setState. Hence it is so much easier to write wrong code with setState than with the other alternatives. To be more helpful, this kind of behavior usually has something to do with your data being prepared in the initState method or some future, and when setState is called, bear in mind your initState or future returning method is probably not rerun. Without seeing your code, I am 80% confident this probably has nothing to do with quill, but the overall data loading strategy of your own code, swap out quill and just work with the rest of your app to show the data somewhere on screen you will probably see the same error message. Double check how your data is loaded and use debugPrint on those lifecycle hooks to see what get called, you will probably find what is wrong. |
@kairan77 Yes indeed, I agree with your feedback. I'd argue the same, don't use setState. Though I'm aware that a whole lot of people wont get it for a very long time and they will use setState. So, I need to make sure the editor stays alive. I just saw today the issue manifesting from code wrote by one of my juniors. It's going to happen a lot even with the best edu materials being available out there. So the goal is to at least keep the editor running in this scenario, performance for sure will suffer (though not greatly for most usecases). I've traced the issue and found a flaw in my current refactoring effort. I'm currently working on a fix. I'll release an explanation once stable. |
Thanks for your feedback. I'm using bloc for bigger projects but this one is very small, just one form, so I decided to just use
Thanks for working on this, looking forward! |
Spirit and Effort admired and appreciated! |
Fixed issue with Avoid setState() Triggering Avoid setState() on text select One common mistake is to react to the selection change in the editor by setting state in the parent. This will induce a needless build cycle in the editor. For example, in the Markers demo page you can see an editor and bellow it a stats panel with numbers indicating the selection extent. Notice that in the demo page implementation we have made special effort to avoid triggering |
Every time I call
setState()
in the parent component which is pretty critical for me. I think it's initialized as late here.Component looks like this when I'm calling

setState
.Code snippet:
I only tried it in web.
Video: https://cdn.discordapp.com/attachments/972503769113829427/996005922193281127/Peek_2022-07-11_12-49.mp4
The text was updated successfully, but these errors were encountered: