Skip to content

Version 7.23.0-next.0

Pre-release
Pre-release
Compare
Choose a tag to compare
@bluebill1049 bluebill1049 released this 30 Dec 01:15
· 591 commits to master since this release

馃捇 Feature/avoid omitting key name use field array (improve DX) (#7301)

const App = () => {
  const { control, register, handleSubmit } = useForm<FormValues>({
    defaultValues: {
      test: [{id: 'UUID5678', test: 'data' }] // id will be remained as it match default keyName
    }
  });
  const { fields, append } = useFieldArray({
    control,
    name: 'test',
  });

  return (
    <form>
      {fields.map((field, index) => {
        return <input key={field.id} {...register(`test.${index}.test`)} />;
      })}

      <button
        type={'button'}
        onClick={() => {
          append({
            id: 'UUID1234', // id value will be remained as it match default keyName
            test: '1234',
          });
        }}
      >
        append
      </button>
      <button>submit</button>
    </form>
  );
};

馃摬 apply useCallback for callback function to improve perf (#7378)
馃惙 test coverage for types (#7311)

thanks to @felixschorer