react-trello icon indicating copy to clipboard operation
react-trello copied to clipboard

Bug react hook useState, useEffect?

Open trongnhan34vn opened this issue 2 years ago • 0 comments

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!

trongnhan34vn avatar Jul 22 '23 17:07 trongnhan34vn