tachybase_todo/packages/client/src/collection-manager/CollectionProvider.tsx

15 lines
521 B
TypeScript
Raw Normal View History

import React from 'react';
import { CollectionContext } from './context';
import { useCollectionManager } from './hooks';
import { CollectionOptions } from './types';
2022-02-25 23:09:42 +08:00
export const CollectionProvider: React.FC<{ name?: string; collection?: CollectionOptions }> = (props) => {
const { name, collection, children } = props;
const { get } = useCollectionManager();
return (
<CollectionContext.Provider value={collection || get(collection?.name || name)}>
{children}
</CollectionContext.Provider>
);
};