anuoua 6c837ee08c
feat: association snapshot (#1438)
* feat: snapshota

* feat: snapshota i18n & bugs

* feat: snapshota association value fix

* feat: snapshota remove require true

* feat: snapshota params.values null fix

* feat: snapshota i18n

* feat: snapshota CR fix

* feat: snapshota field change fix

* feat: snapshota magicstring fix

* feat: snapshota field del fix

* feat: snapshota CR fix

* feat: snapshota tag fix

* feat: snapshota depth < 3

* fix: improve code

* feat: snapshota test

* feat: snapshota remove disabled

* fix: disabled isOverride

---------

Co-authored-by: chenos <chenlinxh@gmail.com>
2023-02-12 14:43:48 +08:00

17 lines
610 B
TypeScript

import React from 'react';
import { CollectionContext } from './context';
import { useCollectionManager } from './hooks';
import { CollectionOptions } from './types';
export const CollectionProvider: React.FC<{ allowNull?: boolean; name?: string; collection?: CollectionOptions }> = (
props,
) => {
const { allowNull, name, collection, children } = props;
const { getCollection } = useCollectionManager();
const value = getCollection(collection || name);
if (!value && !allowNull) {
return null;
}
return <CollectionContext.Provider value={value}>{children}</CollectionContext.Provider>;
};