CollectionManagerProvider

Used to provide CollectionManager instance.

Component

  • Type
interface CollectionManagerProviderProps {
  instance?: CollectionManager;
  dataSource?: string;
  children?: ReactNode;
}
  • Parameter Details

    • dataSource - Data source name. If empty, the default data source will be used.
    • instance - CollectionManager instance. If not provided, will use the collectionManager corresponding to dataSource.
  • Example

const  collectionManager = new CollectionManager();

const Demo = () => {
  return (
    <CollectionManagerProvider dataSource='test'>
      <div>...</div>
    </CollectionManagerProvider>
  );
};

Hooks

useCollectionManager()

Used to get the instance passed by CollectionManagerProvider.

  • Example
const Demo = () => {
  const collectionManager = useCollectionManager();
  const collections = collectionManager.getCollections()

  return <div>
    <pre>{JSON.stringify(collections, null, 2)}</pre>
  </div>;
};
Total visits  times     Total visitors  times     Total reading  times.   Powered by Tego Team