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

Implemented hook for validated state #261

Merged
merged 10 commits into from
Aug 22, 2023
Merged

Conversation

rubenthoms
Copy link
Collaborator

This new hook does work like the default React.useState hook, but in addition to an initial state, it takes a list of valid states and a boolean setting if the state should or should not be updated to a new valid one when the previous one gets invalid.

The hook checks if the previous state is in the list of valid states. If not, the hook returns the first value from the list of valid states but keeps the original state as it might become valid again. However, if the boolean is set to false, the state is not kept but set to this new valid state.

@rubenthoms rubenthoms added the enhancement New feature or request label Aug 18, 2023
@rubenthoms rubenthoms self-assigned this Aug 18, 2023
Copy link
Collaborator

@jorgenherje jorgenherje left a comment

Choose a reason for hiding this comment

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

Looks good to me!

Seems like a hook which can come handy for us!

Copy link
Collaborator

@jorgenherje jorgenherje left a comment

Choose a reason for hiding this comment

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

Looks good to me!

@rubenthoms rubenthoms merged commit e963214 into equinor:main Aug 22, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants