keep-vue
Version:
Keep Vue is an open-source component library built on top of Vue3 and Tailwind CSS. It offers a collection of pre-designed UI components and styles that you can easily integrate into your web applications.
14 lines (13 loc) • 560 B
JavaScript
import { createInjectionState } from "@vueuse/core";
// custom injectionKey
const RatingStoreKey = "rating-store";
const [useProvideRatingStore, useRatingStore] = createInjectionState((handleRating) => {
return { handleRating };
}, { injectionKey: RatingStoreKey });
function useRatingStoreOrThrow() {
const ratingStore = useRatingStore();
if (ratingStore == null)
throw new Error("Please call `useProvideRatingStore` on the appropriate parent component");
return ratingStore;
}
export { useProvideRatingStore, useRatingStoreOrThrow };