Giter VIP home page Giter VIP logo

Comments (2)

seahindeniz avatar seahindeniz commented on June 25, 2024 1

Yes, you are right. The odd part is, I was a bit sure that I got this issue after the upgrade but seems like I got the timeline wrong 😓 I have downgraded the versions on the minimal repo, and it is still reproducible.

I have tracked down to this point

export function createForm<TFieldValues extends FieldValues>(props: {
  initialValues?: FormOptions<TFieldValues>['initialValues'];
}) {
  const scope = createFormModular<TFieldValues>({
    initialValues: props.initialValues,
  });

  return scope;
}

If I comment out the return line in this function, there's no CPU issue. But when I return scope from the function, then the TS Server goes crazy.

After converting the function as the same in the type definition file, problem gone. However, if I don't specify the return type manually, it still causes TS server issue, strange.

Final trial

export function createForm<TFieldValues extends FieldValues, TResponseData extends ResponseData = undefined>(options?: FormOptions<TFieldValues>): [
  FormStore<TFieldValues, TResponseData>,
  {
      Form: (props: Omit<FormProps<TFieldValues, TResponseData>, 'of'>) => JSX.Element;
      Field: <TFieldName extends FieldPath<TFieldValues>>(props: FieldPathValue<TFieldValues, TFieldName> extends MaybeValue<string> ? PartialKey<Omit<FieldProps<TFieldValues, TResponseData, TFieldName>, 'of'>, 'type'> : Omit<FieldProps<TFieldValues, TResponseData, TFieldName>, 'of'>) => JSX.Element;
      FieldArray: <TFieldArrayName extends FieldArrayPath<TFieldValues>>(props: Omit<FieldArrayProps<TFieldValues, TResponseData, TFieldArrayName>, 'of'>) => JSX.Element;
  }
] {
  const scope = createFormModular<TFieldValues, TResponseData>(options);

  return scope;
}

The main point of doing this is to create a reusable facilitator function that creates a form but with a bit of sugar to trigger the validate function when the lang/language gets a reactive update.

Since the above version solves the issue, I guess it is safe to close the issue.
Thank you for leading it to double-check @fabian-hiller 🙏🏻

from valibot.

fabian-hiller avatar fabian-hiller commented on June 25, 2024

Does this problem still occur when you restart your computer? Are you sure it did not happen with the previous version? Can you double check? I do not think this is related to our source code.

from valibot.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.