CollectionProvider

Used to provide Collection instance.

Component

CollectionProvider

  • Type
interface CollectionProviderProps {
  name: string;
  dataSource?: string;
  children?: ReactNode;
}
  • Details

The component will query data table information from CollectionManager based on name. If not found, it will not render.

dataSource is used to specify the namespace where the data table is located. If not specified, defaults to default namespace.

  • Example
import { CollectionProvider } from '@tachybase/client';

const MyComponent = () => {
  return (
    <CollectionProvider name="users">
      <div>...</div>
    </CollectionProvider>
  )
}

Hooks

useCollection()

Used to get the Collection instance passed by CollectionProvider.

const collection = useCollection()

console.log(collection instanceof Collection) // true
console.log(collection);

Use with Mixin:

const collection = useCollection<TestMixin>()
const collection = useCollection<TestMixin & TestMixin2>()

Example

Total visits  times     Total visitors  times     Total reading  times.   Powered by Tego Team