diff --git a/packages/example/src/lib/TextFieldInput.tsx b/packages/example/src/lib/TextFieldInput.tsx index 6c867fb..c61265a 100644 --- a/packages/example/src/lib/TextFieldInput.tsx +++ b/packages/example/src/lib/TextFieldInput.tsx @@ -10,24 +10,27 @@ export type TextFieldInputProps = Omit, "schema"> & export type TextFieldOptionalInputProps = Omit, "schema"> & Omit export const TextFieldInput: { - ( - schema: Schema.Schema - ): Component.Component, React.JSX.Element, ParseResult.ParseError, R> -} = ( - schema: Schema.Schema + (options: { + readonly optional: true + readonly schema: Schema.Schema + }): Component.Component, React.JSX.Element, ParseResult.ParseError, R> + (options: { + readonly optional?: false + readonly schema: Schema.Schema + }): Component.Component, React.JSX.Element, ParseResult.ParseError, R> +} = (options: + { + readonly optional: true + } ): Component.Component< - TextFieldInputProps, + TextFieldOptionalInputProps | TextFieldInputProps, React.JSX.Element, ParseResult.ParseError, R > => Component.makeUntraced(function* TextFieldInput(props) { - const ref = React.useMemo(() => props.optional - ? SubscriptionSubRef.makeFromGetSet(props.ref, { - - }) - : props.ref, - [props.optional, props.ref]) - const input = yield* useInput({ schema, ...props }) + const input = options.optional + ? yield* useOptionalInput({ schema, ...props }) + : yield* useInput({ schema, ...props }) const issues = React.useMemo(() => Option.map( input.error,