I'm developing a webapp where I listen to the selected event on any board component and update the state on the react component, however, after each request, the listener is being triggered 2x compared to the last selection event.
The code is as follows:
function myComponent() {
const [counter, updateCounter] = useState(0);
miro.onReady(() => {
miro.addListener("SELECTION_UPDATED", () => {
console.log("selection updated triggered");
updateCounter((counter) => counter + 1);
})
})
return (
<div>{counter}</div>
)
}
The counter values is doubling the values like follow: 0, 1, 3, 7, 15, 31…
Can someone help me understand what's going on?
Best answer by Max Harper
View original