Replies: 1 comment
-
One thought might be to override the built in |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is not really a super critical feature (unlike #1000 😉 ) IMO but still interesting to discuss.
I realized that since rendering occurs in a rAF it is not possible to
catch
any errors that occur.Ok so why would I want to do that?! – Not 100% sure it makes sense, but: I was working on a proof of concept of a HOA that will persist state in localStorage, and initialize the app with the stored state (when it exists) instead of
init
.This effectively gives you the same behavior as HMR: you change a view component and the app reloads, but it maintains the state it had before it reloads so if you were working on a component that only appears sometimes, you would not have to go through the motions of making it appear – the preview is instant.
example here
The problem with that example though, is that once you've used this, the app will never run with the actual initial state again (even when you're working on a completely different app!). So that's no good, really. At some point you would want the HOA to detect that it should clear the storage and start over. Basically:
...but when? Well I figured a good time would be if the rendering throws some kind of error and we were using stored state. (if the error was due to some other reason we would still see it after the reload from scratch)
Unfortunately there's no way to detect that
patch
throws an error, since it executes within a requestAnimationFrameWhat do you think? Does the idea make sense? Is there a clever workaround?
Beta Was this translation helpful? Give feedback.
All reactions