TinyBase logoTinyBase β

useHasSlice

The useHasSlice hook returns a boolean indicating whether a given Slice exists in an Index, and registers a listener so that any changes to that result will cause a re-render.

useHasSlice(
  indexId: string,
  sliceId: string,
  indexesOrIndexesId?: IndexesOrIndexesId,
): boolean
TypeDescription
indexIdstring

The Id of a possible Index in the Indexes object.

sliceIdstring

The Id of a possible Slice in the Index.

indexesOrIndexesId?IndexesOrIndexesId

The Indexes object to be accessed: omit for the default context Indexes object, provide an Id for a named context Indexes object, or provide an explicit reference.

returnsboolean

Whether a Slice with that Id exists.

This hook follows the same Indexes object resolution rules as the useSliceIds hook.

Since

v9.1.0