Skip to main content

useSetItemPosition

Returns setter functions to change the position of the widget on the dashboard.

function useSetItemPosition(): {setX: SetterOrUpdater<number>; setY: SetterOrUpdater<number>}

Returns

An object with the setter functions setX and setY. Like the setter of useState, they take either the new position in pixels or a function receiving the previous position.

Example

src/widgets/example/Example.tsx
import React from 'react'
import {useSetItemPosition} from '@modbros/dashboard-sdk'

export default function Example() {
const {setX, setY} = useSetItemPosition()

return (
<button
onClick={() => {
setX((x) => x + 10)
setY(0)
}}
>
Move
</button>
)
}