Skip to content

chore: Change usage of ChooseOne (no final condition) #4158

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

Merged
merged 3 commits into from
Sep 27, 2022

Conversation

presleyp
Copy link
Contributor

Based on our conversation in Frontend Variety, I made the condition prop optional in Cond component. ChooseOne will throw an error if you use one on your default case, or don't use one in a non-final case.

@presleyp presleyp requested a review from a team as a code owner September 22, 2022 19:57
@presleyp presleyp requested review from code-asher and removed request for a team September 22, 2022 19:57
Copy link
Member

@code-asher code-asher left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense!! IMO this is even better than what we talked about in FEV. 👍

return chosen ?? childArray[childArray.length - 1]
const conditionedOptions = childArray.slice(0, childArray.length - 1)
const defaultCase = childArray[childArray.length - 1]
if (defaultCase.props.condition !== undefined) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idk if this is worth consideration but if given an empty array defaultCase would be undefined I think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! How does this look?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect!!

@presleyp presleyp merged commit fedb180 into main Sep 27, 2022
@presleyp presleyp deleted the presleyp/chooseone branch September 27, 2022 19:58
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.

2 participants