use-form-control.mdx 845 B

12345678910111213141516171819202122232425262728293031
  1. ---
  2. title: "UseFormControl"
  3. generated: true
  4. ---
  5. <GenerationInfo sourceFile="packages/admin-ui/src/lib/react/src/react-hooks/use-form-control.ts" sourceLine="31" packageName="@vendure/admin-ui" />
  6. Provides access to the current FormControl value and a method to update the value.
  7. *Example*
  8. ```ts
  9. import { useFormControl, ReactFormInputProps } from '@vendure/admin-ui/react';
  10. import React from 'react';
  11. export function ReactNumberInput({ readonly }: ReactFormInputProps) {
  12. const { value, setFormValue } = useFormControl();
  13. const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
  14. setFormValue(val);
  15. };
  16. return (
  17. <div>
  18. <input readOnly={readonly} type="number" onChange={handleChange} value={value} />
  19. </div>
  20. );
  21. }
  22. ```
  23. ```ts title="Signature"
  24. function useFormControl(): void
  25. ```