Hooks API
The custom hooks provided by this package are designed to be used inside the items
.
useData( [data], [options] ) ๐
Parameters
- data ย โย object
- The data of the Item in which the hook is called.
- Optional.
- options.merge ย โย boolean
- Should new data be merged with old ones or replace them?
- Default value:
false
. - Optional.
Returns ย โย setData( data, [options] )
setData( data, [options] )
Function returned by the hook. The identity of the function is guaranteed to be stable so it will be safe to omit them as a dependency (e.g. if it was used inside a useEffect hook).
Parameters
- data ย โย object
- The data of the Item in which the hook is called.
- options.merge ย โย boolean
- Should new data be merged with old ones or replace them?
- Default value:
false
. - Optional.
Default options
Default options used by setData, useData.
useDrag( ) ๐
The Item will re-render on each drag start/end.
Returns ย โย boolean
useDraggable( ) ๐
Return the drag enabler method.
Returns ย โย setDraggable( )
setDraggable( draggable )
Function returned by the hook. The identity of the function is guaranteed to be stable so it will be safe to omit them as a dependency (e.g. if it was used inside a useEffect hook).
Parameters
- draggable ย โย boolean
- A truthy value to allow the Item to be dragged, a falsy value to not allow the Item to be dragged.
useGrid( ) ๐
Returns ย โย GridData
- GridData.id ย โย string
- The id of the MuuriComponent of which the Item is a child.
- GridData.groupIds ย โย array
- The group ids of the MuuriComponent of which the Item is a child.
- GridData.grid ย โย Muuri
- The Muuri instance of the MuuriComponent of which the Item is a child.
useRefresh( [deps] ) ๐
Show the targeted Items.
Parameters
- deps ย โย array
- An array of dependencies, it has the same purpose as in useEffect.
- Default value:
[]
. - Optional.
Returns ย โย refresh( )
refresh( )
Function returned by the hook. The identity of the function is guaranteed to be stable so it will be safe to omit them as a dependency (e.g. if it was used inside a useEffect hook).
useShow( ) ๐
The Item will re-render each time its visibility change.
Returns ย โย boolean
useVisibility( ) ๐
Return the visibility setter method.
Returns ย โย setVisibility( )
setVisibility( visibility, [options] )
Function returned by the hook. The identity of the function is guaranteed to be stable so it will be safe to omit them as a dependency (e.g. if it was used inside a useEffect hook).
Parameters
visibility ย โย boolean
- A truthy value to show the Item, a falsy value to hide the Item.
options.instant ย โย boolean
- Should the animation happen instantly?
- Default value:
false
. - Optional.
Default options
Default options used by setVisibility.