When clicking on a candidate on the grid, the toggle function runs twice.
On single-select mode, that means that it toggles it on and off and so does nothing.
On multi-select mode, somehow, something with the way I set it up makes it so running it twice does not undo it.
The problem is that clicking a candidate on the grid is both selecting it and toggling the candidate. The toggle candidate function operates on the selected cells, and it doesn't wait until the clicked cell is added to the selected group. So I added an optional parameter to the toggle candidates function that's "do this for the selected cells, and make sure that this cell here is also included". Though, in single-select mode, it would only be operating on the one cell, so it bypasses looking at anything that was previously selected.
So there's like something about the lifecycle or re-rendering or something that's making it happen twice? Maybe there needs to be something with useEffect or useCallback??
We decided that it had something to do with including the <React.StrictMode > in client/src/index.js, because it was running both the script from the build folder and from the not-compiled folders.
When clicking on a candidate on the grid, the toggle function runs twice.
On single-select mode, that means that it toggles it on and off and so does nothing.
On multi-select mode, somehow, something with the way I set it up makes it so running it twice does not undo it.
The problem is that clicking a candidate on the grid is both selecting it and toggling the candidate. The toggle candidate function operates on the selected cells, and it doesn't wait until the clicked cell is added to the selected group. So I added an optional parameter to the toggle candidates function that's "do this for the selected cells, and make sure that this cell here is also included". Though, in single-select mode, it would only be operating on the one cell, so it bypasses looking at anything that was previously selected.
So there's like something about the lifecycle or re-rendering or something that's making it happen twice? Maybe there needs to be something with useEffect or useCallback??