Skip to content

Conversation

@gurch101
Copy link
Contributor

using props to set the initial state of the checkbox results in the duplication of the "true state" of the checkbox in both this code and the caller that handles the onClick callback. Make this component stateless so that the caller is the main "keeper of the state".

Example where the current code would fail:
Have a screen with a "Reset Checkbox" button. Clicking this button would do nothing since the props change is not handled. One solution would be to add componentWillReceiveProps but I'd imagine the caller would almost always maintain the checkbox state itself through the onClick callback.

@rgoldiez
Copy link

Alternatively, have the onClick call back return the new state of the component. The current implementation has it's own state but requires the parent component to find state of the checkbox to know how to update state at a higher level.

@ianhowe76
Copy link

I have created an alternative option to to allow component to be used in current uncontrolled mode

#12

@crazycodeboy crazycodeboy merged commit dbd4083 into crazycodeboy:master Mar 6, 2017
@grahammcculloch
Copy link

@crazycodeboy any chance of creating a release that includes the commit from this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants