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.

[v6.0.6] Bug: Checkboxes are always being cast to strings despite providing boolean default value.

See original GitHub issue

Describe the bug I’m trying to use react-hook-form with checkboxes and even though the default values for said checkboxes are all booleans (false), as soon as I interact with the checkbox the form value gets cast to a string. I was able to reproduce this fully in the codesandbox below.

To Reproduce

  1. Create checkbox components with default values that are booleans
  2. watch the values
  3. check them and you will see that they are cast to strings.

Codesandbox link (Required) https://codesandbox.io/s/react-hook-form-checkboxes-get-cast-to-strings-everytime-lioo1?file=/src/index.js

Expected behavior I expect the checkboxes to not get cast into strings and simply change from true to false and vice versa.

Screenshots image

@bluebill1049 it seems checkbox behaviour also randomly changed, i don’t think I had this problem with older versions but will also double check.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
harrisrobincommented, Jul 16, 2020

@bluebill1049 I think some improvements to the docs with more checkbox examples and a search feature would help. I’ll take a look at how the docs are setup and see if I can contribute something here.

3reactions
bluebill1049commented, Jul 16, 2020
Screen Shot 2020-07-17 at 9 08 35 am Screen Shot 2020-07-17 at 9 08 57 am

updated both the doc and CSB to emphasize checkbox example.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Toggle Angular checkbox with string values instead of ...
The checkbox toggles values as "optin" or "optout" when checked/unchecked and is initialized as "optin" by default in .ts file.
Read more >
Changelog - Cypress Documentation
Fixed an issue with Angular Component Testing where urls within SASS/SCSS files were not being correctly resolved which could result in incomplete styling....
Read more >
Fix list for IBM WebSphere Application Server V8.5
IBM WebSphere Application Server provides periodic fixes for the base and Network Deployment editions of release V8.5. The following is a complete listing ......
Read more >
React Hooks Checkbox Not Setting Checked To True And False
Ask questions[v6.0.6] Bug: Checkboxes are always being cast to strings despite providing boolean default value. Describe the bug I'm trying to use.
Read more >
Solved: Problem with checkbox.value = boolean
Now the problem, when I verify if checkbox.value = false its returns ... What I'm doing is converting value to string to solve...
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