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

Lifecycle diagram unmounted => onUnmounted #2682

Open
orionna319 opened this issue Jan 26, 2024 · 7 comments
Open

Lifecycle diagram unmounted => onUnmounted #2682

orionna319 opened this issue Jan 26, 2024 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@orionna319
Copy link

lifecycle-diagram

Thanks to the community for their contribution. When I used the documentation, I found that the flow chart was inconsistent with the actual situation.

unmounted => onUnmounted

image

@brc-dd
Copy link
Member

brc-dd commented Jan 26, 2024

Why? I think it's consistent with the naming of other things that are mentioned there like mounted, beforeMount, updated, beforeUpdate... onUnmounted is the hook, unmounted is the event.

@brc-dd brc-dd closed this as completed Jan 26, 2024
@brc-dd brc-dd reopened this Jan 26, 2024
@orionna319
Copy link
Author

onUnmounted is the hook, unmounted is the event, you are correct.

When I was not very familiar with Lifecycle Hooks, I would look at this flow chart, because mounted is a hook in vue2, so I would think that unmounted is also a hook, and then I would import { unmounted } from 'vue', which confuses me

onUnmounted is the hook, unmounted is the event.

@brc-dd
Copy link
Member

brc-dd commented Jan 26, 2024

Ah, actually if you're using options API, it's still unmounted:

export default {
  unmounted() {
    // ...
  }
}

If you read that page completely, then the section above that image shows the usage (depending on your choice of options/compositions API).

event might be wrong technical term in my earlier comment. I believe it's more like onUnmounted is for composition API, unmounted is for options API. And the diagram explicitly mentions options API.

@orionna319
Copy link
Author

So the text described by the red border in the lifecycle-diagram is a hook, but it is a hook for the options API. Since the composition API is officially recommended, can we have a lifecycle-diagram corresponding to the options API and composition API?

The API Preference in the current document defaults to the composition API, and lifecycle-diagram displays the options API hooks. When we switch the API Preference, it may be better to display the lifecycle-diagram corresponding to the hooks.

@bencodezen
Copy link
Member

When we switch the API Preference, it may be better to display the lifecycle-diagram corresponding to the hooks.

@orionna319 This is a great suggestion! I'll take a look at how we can implement this.

@bencodezen bencodezen self-assigned this Jan 30, 2024
@bencodezen bencodezen added the enhancement New feature or request label Jan 30, 2024
@bencodezen
Copy link
Member

@orionna319 Sorry for the delay on this. Currently working on the best way to explain this, but what do you think of this draft diagram?

lifecycle-composition

@orionna319
Copy link
Author

Amazing work. Thank you very much for your contribution, which allows us to better understand composition-api-lifecycle. I'm sorry to reply to you a few days late. I have a question here, onCreated It seems that it is not in composition-api-lifecycle, in the official document.

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

No branches or pull requests

3 participants