Skip to content

Commit

Permalink
Version Packages (beta) (#5)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
github-actions[bot] and github-actions[bot] authored May 24, 2022
1 parent 56dbc26 commit 2cdc522
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .changeset/pre.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@
"initialVersions": {
"@radiantguild/form-contexts": "0.1.3"
},
"changesets": []
"changesets": [
"dry-clocks-double"
]
}
25 changes: 25 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
# @radiantguild/form-contexts

## 0.2.0-beta.0

### Minor Changes

- [#4](https://github.com/RadiantGuild/Lib.FormContexts/pull/4) [`56dbc26`](https://github.com/RadiantGuild/Lib.FormContexts/commit/56dbc264026a7ff6b1dd4ead4988ab16f5b27395) Thanks [@Alduino](https://github.com/Alduino)! - Added the `useInitialValidationUpdate` hook, which can be used to have some validation state that will clear when a new one is set.

The hook was created for the use-case where you have "instant" validation that can respond as a user types in a value, as well as delayed validation that you can only get e.g. when you submit the form.

You can still use the normal `useValidationUpdate` hook for instant validation results, but now instead of using that hook for delayed validation, you call `useInitialValidationUpdate`.

When using synchronous validation, this hook will act the same as `useValidationUpdate` (although it acts as a fallback when the standard funtion is called with `null`).

If you use asynchronous validation, the hook becomes a bit more fancy, as it can keep showing the initial validation result until the standard one has finished loading. Specifically, it will show until the next loading state finishes.

Here's a minimal example to give you an idea of how it might be used:

```jsx
// serverSideError is set whenever the user clicks a submit button
useInitialValidationUpdate(props.serverSideError);

// value is the current value of the input, set in an onChange handler
const validateResult = useValidation(props.value, props.validators);
useValidationUpdate(validateResult);
```

## 0.1.3

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@radiantguild/form-contexts",
"version": "0.1.3",
"version": "0.2.0-beta.0",
"type": "module",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down

0 comments on commit 2cdc522

Please sign in to comment.