You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's not that much of a problem .. But I am of that kind of people who feel it a tedious process to import the useStore and execute it to just use a single state item inside the template.
Proposed solution
A built-in renderless data provider component which passes the store to the template through a the default slot. In fact I use this method inside my projects but it would be good if there is a built-in component for this purpose.
Define a renderless data-provider component
/**
* StoreProvider.vue
* A renderless store-provider component
*/
<script lang="ts">
import {defineComponent} from "vue";
import {useLayoutStore} from "@/js/store";
export default defineComponent({
setup(props: any, ctx) {
const store = useLayoutStore()
return () => ctx.slots.default(store)
}
})
</script>
This discussion was converted from issue #2801 on October 19, 2024 11:11.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
What problem is this solving
It's not that much of a problem .. But I am of that kind of people who feel it a tedious process to import the useStore and execute it to just use a single state item inside the template.
Proposed solution
A built-in renderless data provider component which passes the store to the template through a the default slot. In fact I use this method inside my projects but it would be good if there is a built-in component for this purpose.
Define a renderless data-provider component
Import the component globally
Use the provider inside your app
Describe alternatives you've considered
It would be very nice if this component has a props to accept the name of the store to dynamically import and provide it.
Beta Was this translation helpful? Give feedback.
All reactions