[Question] How to get the most updated Board data?
Hello guys,
I have been playing with React-Trello and Socket IO, so once some user updates a card via a modal, another user can directly see it, but there is a problem.
Once the user closes the modal and open again we only have the old state, by using the board data.
const handleCardClick = (cardId, metadata, laneId) => {
const item = boardData.lanes.find(x => x.id === laneId).cards.find(x => x.id === cardId);
setModalItem(item);
handleOpen();
}
I am using the useState Hook for getting and keep the data. Sadly, the variable does not update itself, so I am using onDataChange like that:
const handleDataChange = (data) => {
if(data !== undefined) setBoardData(data);
}
However, I don't think it is a good practice. How do you think we can improve this, there is another way someone else is using for React-trello? Could the onCardClick also send the full board data, instead of only the cardId and LaneID?
@guifeliper I have a similar use case, and have resorted to updating the state in handleDataChange. It doesn't seem to be the best idea - were you able to find a better solution?