useValidatedState

Keep a value together with its validity and the last value that was valid.

This is custom React hooks, you need to follow the Basic Rules when you use it.

General

The email is valid when it matches a simple pattern.

APIs

useValidatedState

const useValidatedState = <T>(
  initialValue: T,
  validate: (value: T) => boolean,
) => [
  { value: T; lastValidValue: T | undefined; valid: boolean },
  (value: T) => void,
]
Edit this page on GitHub