Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

React crash when using getCheckboxProps or getRadioProps conditionally #3332

Open
unekinn opened this issue Mar 7, 2025 · 0 comments · May be fixed by #3342
Open

React crash when using getCheckboxProps or getRadioProps conditionally #3332

unekinn opened this issue Mar 7, 2025 · 0 comments · May be fixed by #3342
Assignees
Labels
🐛 bug Something isn't working react @digdir/designsystemet-react

Comments

@unekinn
Copy link
Contributor

unekinn commented Mar 7, 2025

Version number

1.0.0

Description of the bug

React crashes with reference to the number of rendered hooks if e.g. a table with a row of checkboxes has paging or filtering, and renders fewer rows than it did on initial render.

This is due to getCheckboxProps and getRadioProps using hooks internally, but these functions are not hooks and should not use hooks.

Steps To Reproduce

  1. Checkout branch getCheckboxProps-crash
  2. Run Storybook
  3. Go to "Komponenter > Checkbox > Conditional", click "Rediger", see crash

    Rendered more hooks than during the previous render.

  4. Go to "Komponenter > Checkbox > In Table With Pagination", click "Neste", see crash

    Rendered fewer hooks than expected. This may be caused by an accidental early return statement.

Additional Information

No response

@unekinn unekinn added the 🐛 bug Something isn't working label Mar 7, 2025
@mimarz mimarz added the react @digdir/designsystemet-react label Mar 7, 2025
@mimarz mimarz moved this from 🔵 Inbox to 📄 Todo in Team Designsystemet Mar 7, 2025
@mimarz mimarz moved this from 📄 Todo to 🏗 In progress in Team Designsystemet Mar 11, 2025
@mimarz mimarz moved this from 🏗 In progress to 👀 Ready for review in Team Designsystemet Mar 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working react @digdir/designsystemet-react
Projects
Status: 👀 Ready for review
3 participants