question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

useRowSelect not work with React.StrictMode

See original GitHub issue

Describe the bug (required)

When using React.StrictMode in conjunction with useRowSelect, I cannot select more than one row. And in selectedRowIds I only get data from the first selection

Provide an example via Codesandbox! (required) I fork base useRowSelect example and add React.StrictMode. Exsample

Steps To Reproduce (required) 0. State before:

"selectedRowIds": {},
  1. Select first line.
"selectedRowIds": {
    "0": true,
    "0.0": true,
    "0.1": true,
    "0.2": true
  } 
  1. Select second line
"selectedRowIds": {
    "0": true,
    "0.0": true,
    "0.1": true,
    "0.2": true
  } 
  1. Select third line
"selectedRowIds": {
    "0": true,
    "0.0": true,
    "0.1": true,
    "0.2": true
  } 

Expected behavior (Recommended) 0. State before:

"selectedRowIds": {},
  1. Select first line.
"selectedRowIds": {
    "0": true,
    "0.0": true,
    "0.1": true,
    "0.2": true
  } 
  1. Select second line
"selectedRowIds": {
    "0": true,
    "1": true,
    "0.0": true,
    "0.1": true,
    "0.2": true,
    "1.0": true,
    "1.1": true,
    "1.2": true
  },
  1. Select third line
{
  "selectedRowIds": {
    "0": true,
    "1": true,
    "2": true,
    "0.0": true,
    "0.1": true,
    "0.2": true,
    "1.0": true,
    "1.1": true,
    "1.2": true,
    "2.0": true,
    "2.1": true,
    "2.2": true
  },

Desktop (please complete the following information):

  • OS: macOS 10.15.2
  • Google Chrome
  • Version 80.0.3987.149

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:7
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
spectrascommented, Apr 15, 2020

Here is another sandbox that shows the problem:

https://codesandbox.io/s/hopeful-elion-9ueg9?file=/src/index.js

To reproduce:

  • Simply tick the checkbox in order.
  • As you tick the 3rd checkbox, the 2nd will untick itself.
  • Also, the selection count does not get updated.

Without strict mode:

  • Comment out the two strict mode lines on the left.
  • Everything works as expected (checkboxes have consistent behavior, and selection count is updated).

Ideas I believe this could come from either of two design issues (or the combination of both).

  1. There are side effects in a useMemo hook — opened #2170 about this.

  2. The state reducer reads state outside of previousState, which may or may not be up to date (resolving this ambiguity is the whole point of the reducer pattern). — opened #2171 about this.

0reactions
tannerlinsleycommented, May 5, 2020

Going to track this in #2170

Read more comments on GitHub >

github_iconTop Results From Across the Web

useRowSelect not work with React.StrictMode #2120 - GitHub
Describe the bug (required) When using React.StrictMode in conjunction with useRowSelect, I cannot select more than one row.
Read more >
Strict Mode - React
Strict mode checks are run in development mode only; they do not impact the production build. You can enable strict mode for any...
Read more >
React Table - radio input for useRowSelect - Stack Overflow
I am trying to exclusively select only 1 row at at time, and I see that your code only does this if including...
Read more >
React Table Row Select Strict Mode Broken - CodeSandbox
Activating extension 'vscode.typescript-language-features' failed: Could not find bundled tsserver.js.
Read more >
gettoggleallrowsselectedprops is not a function - You.com | The ...
I added a special column with checkbox, but keep getting strange error: "TypeError: props.getToggleAllRowsSelectedProps is not a function".
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found