How to use a function within useState
Based on the requirement mentioned, I think you don't need the callback format for setState
and you can simply do
const [colors, setColors] = useState([])
function onSortEnd({ oldIndex, newIndex }) {
const newColors = arrayMove(colors, oldIndex, newIndex);
setColors(newColors);
};