mirror of
https://github.com/youzan/vant.git
synced 2025-10-18 01:17:15 +00:00
fix: useParent default value
This commit is contained in:
@@ -4,7 +4,10 @@ type Parent = { children: unknown[] };
|
||||
|
||||
type Child<T> = T extends { children: (infer U)[] } ? U : never;
|
||||
|
||||
export function useParent<P extends Parent>(key: string, child: Child<P>) {
|
||||
export function useParent<P extends Parent>(
|
||||
key: string,
|
||||
child = {} as Child<P>
|
||||
) {
|
||||
const parent = inject<P | null>(key, null);
|
||||
|
||||
if (parent) {
|
||||
|
Reference in New Issue
Block a user