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

FormChoice Doesn't allow for false as a value override #957

Open
CRiva opened this issue Feb 3, 2022 · 0 comments
Open

FormChoice Doesn't allow for false as a value override #957

CRiva opened this issue Feb 3, 2022 · 0 comments

Comments

@CRiva
Copy link
Contributor

CRiva commented Feb 3, 2022

In the react app I'm working on, I have controlled state for a form, so I wish to have one radio button be the true and another be the false like so (removed specific names for generic sake):

          <FormRow
            id='js-technical-resources'
            onChange={e => myFucntion(e.target.value)}
            stacked
            type='radio'
          >
            <FormChoice
              key='option 1'
              name='option 1'
              checked={!stateVariable}
              value={false}
            >
              Option 1
            </FormChoice>
            <FormChoice
              key='Option 2'
              name='Option 2'
              checked={stateVariable}
              value={!!true}
            >
              Option 2
            </FormChoice>
          </FormRow>

But this doesn't pass in false as the value when Option 1 is selected due to this computedValue in the FormChoice Component.

    const computedValue = value || children;

It computes to the {children} which in this case is just the string Option 1.

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

No branches or pull requests

1 participant