-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Rename onrender/onteardown to oncreate/ondestroy #40
Comments
In regards to 1, it'd also be nice to know if components can be rerendered/reconstructed/remounted manually, either in place or in a new target. On 2, perhaps consider reusing names from other frameworks, whichever's aligned with svelte's implementation: Custom Elements v1's |
I would go with |
I'd be fine with that as well, with the caveat that |
Agreeing with you @aickin - its VERY important to have a clear and concise api, that can be consumed and understood at first glace. Much like React's will / did ComponentUpdate lifecycles. |
What about |
@Rich-Harris yeah mate - love it!!! |
+1 for |
Might I suggest following the Custom Elements v1 spec for the names of lifecycle hooks? I think that's most forward looking, even though not as concise.
|
my $0.02 when I first saw |
In Python's unittest you use |
I actually think react did a good job finding names for these lifecycle events:
Well those names are a bit verbose, I would maybe call them I think there is an edge case involving yield fragments with the current |
I've opened #316 which implements Re alternative name suggestions, I'm wary of using the same names that web components and React use, partly because they're kinda ugly and tedious to type (and don't gel with all the other single-word-all-lowercase properties), but mostly because when you do that, you need to get the semantics exactly the same otherwise you just end up confusing people. For example, my understanding is that |
[WIP] warn on onrender/onteardown, replace with oncreate/ondestroy
The deprecated method onrender() is used in one of the examples. Change to oncreate(). See sveltejs/svelte#40
This is a very subjective issue and probably deeply affected by my experience with React, but the name
onrender
was quite confusing to me. I presumed thatonrender
would be called every time the component's DOM changed (i.e. every time it is rendered to HTML) rather than just once when the component is added to the document. (By the way, I presume that it's only called when the component is added to the doc based on the code samples; the documentation does not say one way or another.)Two suggestions:
onrender
toonsetup
. In my experience, "setup" is more usually used as a counterpart to "teardown". Another possibility would be something likeonaddtodocument
andonremovefromdocument
.As I say, this is super subjective, but it was legitimately confusing to me while reading over code, even after I figured out that
onrender
is only called on setup.Thanks so much!
The text was updated successfully, but these errors were encountered: