Comments (4)
Hi @seyade ,
The defaultChecked
is not a property of Checkbox
but instead of CheckboxGroup
.
Applying defaultChecked
to the checkboxGroup
will check all checkboxes by default.
If you wish to check a single Checkbox
you can simply pass checked
to it.
from grouped-checkboxes.
Thanks @AlexLisenkov for replying. And great work by the way!
I think defaultChecked
should also be applied to Checkbox
as it is a supported props in React. For example I have a table full of checkboxes (about 50) in all columns and rows. I can populate the checkboxes with data from an api, but I also want to give users the choice to uncheck/check a populated checkbox. Using defaultChecked
makes life easier in this context, I think.
from grouped-checkboxes.
Thank you for pointing out this issue, I believe there is something wrong with a Checkbox being controlled or not.
The misunderstanding, or flaw, is that the checked prop is now behaving like a defaultChecked. I agree with you, and the defaultChecked should be allowed and set the initial checked state.
If we add the defaultChecked there we will be left with the choice about what we should do with the checked prop.
-
Disallow (or ignore) the checked prop, making it impossible to control checked states. Checkboxes will always and only be controlled by the group.
-
Allow the checked prop, making it behave exactly like a checkbox. But making a checkbox controlled it will be impossible to make use of the allCheckers and noneCheckers, because they're not in charge of the state of a checkbox anymore.
Going for option 2 will be nice in a way that it will behave like a checkbox as how we're used to it. But it will also void the main feature of this package, easily add a checkbox to check all.
Can you give your opinion?
from grouped-checkboxes.
I guess, the most viable option will be to leave as it is since checked
prop is the main prop for controlling state. Unless you give the user option to choose between defaultChecked
and checked
when necessary, but that will be too much for something simple like this.
from grouped-checkboxes.
Related Issues (8)
- Minor fix required in documentation 😅 HOT 1
- Infinite re-rendering when trying to update a state with CheckboxGroup HOT 4
- individual checkbox remains selected even after the state change HOT 1
- Nested CheckboxGroup HOT 1
- firing onChange on moving away component
- It'd be nice to be able to shift-click a selection of a large CheckboxGroup HOT 3
- Logging dynamic ID's to console HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grouped-checkboxes.