I'm having a hard time trying to convert my component. My main confusion is the useState. In my class based component it's easy to update my state with this.setState
, but with hooks I'm quite confused about how thats achieved?
for example I can do this
onDrag = (event, item, currentDropZoneId, currentDropZoneItems) => {
event.preventDefault();
console.log("source", currentDropZoneId);
this.setState({
dragSource: currentDropZoneId,
draggedItem: item
});
};
and then use it my JSX
<Item
draggable
onDrag={event => this.onDrag(event, item, dropZone.id)}
ey={item.id}
/>
How do I achieve the same functionality but with hooks? What is this.setState
equalivent in react hooks?