Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug react hook useState, useEffect? #529

Open
trongnhan34vn opened this issue Jul 22, 2023 · 0 comments
Open

Bug react hook useState, useEffect? #529

trongnhan34vn opened this issue Jul 22, 2023 · 0 comments

Comments

@trongnhan34vn
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant