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

Fetcher with key not resetting when key changes #11008

Closed
1 task done
jahvi opened this issue Nov 9, 2023 · 3 comments · Fixed by #11009
Closed
1 task done

Fetcher with key not resetting when key changes #11008

jahvi opened this issue Nov 9, 2023 · 3 comments · Fixed by #11009

Comments

@jahvi
Copy link

jahvi commented Nov 9, 2023

What version of Remix are you using?

2.2.0

Are all your remix dependencies & dev-dependencies using the same version?

  • Yes

Steps to Reproduce

Consider the following route:

app/routes/$id.tsx

import { Link, useParams } from '@remix-run/react';
import { useFetcher } from '@remix-run/react';

export const action = () => {
  return json({ test: 'This is action data' });
};

export default function Page() {
  const params = useParams();
  const fetcher = useFetcher({
    key: params.id,
  });

  return (
    <div>
      <h1>Fetcher Key: {params.id}</h1>

      {fetcher.data ? (
        <>
          <p>This shouldn't show on route change:</p>
          <pre>{JSON.stringify(fetcher.data)}</pre>
        </>
      ) : null}

      <fetcher.Form method="POST">
        <button>Submit then click "Link"</button>
      </fetcher.Form>

      <Link to="../test">Link</Link>
    </div>
  );
}

Demo: https://stackblitz.com/edit/remix-run-remix-gt3qmm?file=app%2Froutes%2F_index.tsx,app%2Froutes%2F%24id.tsx

Expected Behavior

Fetcher data should be undefined

Actual Behavior

Fetcher data does not change

@brophdawg11 brophdawg11 transferred this issue from remix-run/remix Nov 9, 2023
@brophdawg11 brophdawg11 linked a pull request Nov 9, 2023 that will close this issue
@brophdawg11 brophdawg11 self-assigned this Nov 9, 2023
@brophdawg11
Copy link
Contributor

Fixed by #11008 - will be available in the next release

@brophdawg11 brophdawg11 added the awaiting release This issue have been fixed and will be released soon label Nov 13, 2023
@brophdawg11 brophdawg11 removed their assignment Nov 13, 2023
Copy link
Contributor

🤖 Hello there,

We just published version 6.19.0-pre.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

Copy link
Contributor

🤖 Hello there,

We just published version 6.19.0 which involves this issue. If you'd like to take it for a test run please try it out and let us know what you think!

Thanks!

@brophdawg11 brophdawg11 removed the awaiting release This issue have been fixed and will be released soon label Nov 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants