Skip to content
Discussion options

You must be logged in to vote

You can do this actually very easily yourself by adding a value field that goes unused:

import { createFormHook, createFormHookContexts } from "@tanstack/react-form";

function NumberField({ label }: { label: string, value: number }) {
  const field = useFieldContext<number>();
  return (
    <label>
      <div>{label}</div>
      <input
        value={field.state.value}
        onChange={(e) => field.handleChange(e.target.valueAsNumber)}
      />
    </label>
  );
}

const { fieldContext, formContext, useFieldContext } = createFormHookContexts();
const { useAppForm } = createFormHook({
  fieldContext,
  formContext,
  fieldComponents: {
    NumberField: NumberField,
  },
  formComponents…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by crutchcorn
Comment options

You must be logged in to vote
2 replies
@vkhalikov
Comment options

@Ziothh
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants