How to setState in onDragStateChanged
HughLK opened this issue · 1 comments
HughLK commented
I want to show some tips at the top of SortableTree when drag is starting. So I called setState in onDragStateChanged . But it seems not work . How can I fix this?
const [dragState, setDragState] = useState(false);
<DragState draggingState={draggingState.current} />
<div>
<SortableTree
...
onDragStateChanged={({ isDragging, draggedNode }: OnDragStateChangedData) => {
setDragState(isDragging);
}}
/>
</div>
function DragState(props) {
return props.draggingState ? (
<div className="dragging-tip">
<span>tips...</span>
</div>) : null
}
HughLK commented
Currently, I use "setTimtout" to setState.