Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Redirect Doesn't Work with useForm following the docs #6492

Closed
daninus14 opened this issue Nov 14, 2024 · 1 comment
Closed

[BUG] Redirect Doesn't Work with useForm following the docs #6492

daninus14 opened this issue Nov 14, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@daninus14
Copy link
Contributor

Describe the bug

I get this error when trying to add redirect on a useForm

Object literal may only specify known properties, and 'redirect' does not exist in type 'UseFormProps<BaseRecord, HttpError, FieldValues, {}, BaseRecord, BaseRecord, HttpError>'.ts(2353)

Steps To Reproduce

import { useForm } from "@refinedev/react-hook-form";
  const {
    refineCore: { onFinish },
    register,
    handleSubmit,
    formState: { errors },
  } = useForm({redirect: "show",});

Expected behavior

For it to work per the docs https://refine.dev/tutorial/routing/redirects/react-router/#showing-the-record-after-update

Packages

  • @refinedev/react-hook-form

Additional Context

Was trying to follow the tutorial here https://refine.dev/tutorial/routing/redirects/react-router/#showing-the-record-after-update

@daninus14 daninus14 added the bug Something isn't working label Nov 14, 2024
@alicanerdurmaz
Copy link
Member

alicanerdurmaz commented Nov 15, 2024

Hello @daninus14,

In the tutorial, we use useForm from "@refinedev/core", but if you want to use it from "@refinedev/react-hook-form", the API might be a bit different.

To make it work, you need to pass the redirect prop like this:

import { useForm } from "@refinedev/react-hook-form";

useForm({
  refineCoreProps: {
    redirect: false,
  },
});

Sorry for the confusion. The name refineCoreProps is different because @refinedev/react-hook-form internally uses the core functionality from @refinedev/core. To pass specific options or configurations to the core, these are grouped under the refineCoreProps property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants