Skip to content

Bug react hook useState, useEffect? #529

Description

@trongnhan34vn

Describe the bug
Hello guys,

I have trouble with using react hook useEffect and useState. I'm using 'onCardClick' to catch the event 'click on card' and then i set state. But then i can drag anymore.
Can you tell me where the problem is? How can I use react hook with this library?

Here is my code:

function App() {
  const [cardId, setCardId] = useState<string | null>(null);
  const [dataDB, setDataDB] = useState<BoardData>(data);

  // useEffect(() => {
  //   setDataDB(data);
  // }, []);

  const handleDataChange = (data: BoardData) => {
    if (data !== undefined) setDataDB(data);
  };

  const handleClick = (cardId: string) => {
    setCardId(cardId);
  };

  return (
    <div>
      <Board
        onCardClick={handleClick}
        onDataChange={handleDataChange}
        editable
        draggable
        cardDraggable
        data={dataDB}
      />
      <Modal cardId={cardId} />
    </div>
  );
}

Thank you!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions