Nuxt UI - How to use a reactive array as NavigationMenu children?
I have a reactive object. I want to map it as a reactive array to NavigationMenu children array. How to keep reactivity?
2 Replies
Hi @Antza. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
To use a reactive array as the children of a Nuxt UI
NavigationMenu item and keep it reactive, you should define your children as a computed property or a ref, and assign it to the children property of your menu item. The NavigationMenu component supports reactivity because it works with Vue's reactivity system.
Here's an example pattern based on the official documentation:
If you want the children property itself to update reactively when docsList changes, you should use a computed property for the entire items array:
This approach ensures that any changes to your reactive source (docsList) are reflected in the NavigationMenu automatically, maintaining full reactivity as supported by Vue and Nuxt UI NavigationMenu Usage.
You can use refs or computed properties for the---------------------- Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: ----------------------itemsandchildrenarrays, and the NavigationMenu will update reactively when the underlying data changes NavigationMenu Usage.
<@295542272773193729> Kapa.ai is still learning and improving, please let me know how I did by reacting below.