I am trying to create a custom checkbox component (three states, actually, but it doesn’t matter, except to say that I’m not just using INPUT), and I’m not sure how to do this to change the “verification check” from clicking on myself and from a set of values coming from a parent.
I am currently working as a self-contained component that accepts onChange support with a handler callback that it calls to send the value of the parent component after clicks. It uses state to save the check referenced by the display.
If it were just an exponential control, with a value controlled externally, I would use props, of course. If it were only a self-contained checkbox element that accepted the initial value, but only responded to clicks, I would use a state like me, but my problem is that I want it to be available to turn on and off, and allow parent enable and disable it.
I am starting to react and “React”, so I suspect that I am just approaching this wrong. I get the impression that the right way to do this would only consist of a display-only component that passed clicks to the parent to deal with, and in turn received props updates to change values from the parent, but that would do the component is much less reusable in my opinion.
So, how do I change the flag from both internal and parent sources?
Relevant links are also welcome.
source share