From e893efd60d0301b6c36a890eb453168f0a640b03 Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Mon, 24 Aug 2020 19:02:13 +0800 Subject: [PATCH] refactor: remove useChildren --- src/action-bar/index.js | 5 +++-- src/api/use-relation.ts | 8 +------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/action-bar/index.js b/src/action-bar/index.js index ee2623114..bcbb1830b 100644 --- a/src/action-bar/index.js +++ b/src/action-bar/index.js @@ -1,5 +1,5 @@ +import { ref, provide } from 'vue'; import { createNamespace } from '../utils'; -import { useChildren } from '../api/use-relation'; const [createComponent, bem] = createNamespace('action-bar'); @@ -14,7 +14,8 @@ export default createComponent({ }, setup(props, { slots }) { - useChildren(ACTION_BAR_KEY); + const children = ref([]); + provide(ACTION_BAR_KEY, children); return () => (
diff --git a/src/api/use-relation.ts b/src/api/use-relation.ts index d7ab9a027..857ebf04d 100644 --- a/src/api/use-relation.ts +++ b/src/api/use-relation.ts @@ -1,15 +1,9 @@ -import { ref, Ref, provide, inject, computed, onUnmounted } from 'vue'; +import { Ref, inject, computed, onUnmounted } from 'vue'; export type Parent = null | { children: Ref[]>; }; -export function useChildren(key: string) { - const children = ref([]); - provide(key, { children }); - return children; -} - export function useParent(key: string, child: Ref) { const parent = inject>(key, null);