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

Enabling Single Fetch #876

Closed
wants to merge 12 commits into from
Closed

Conversation

hakimLyon
Copy link
Contributor

This PR enables the v3_singleFetch feature.

@kentcdodds
Copy link
Member

Thank you! Could you debug the playwright failures please?

@hakimLyon hakimLyon closed this Oct 16, 2024
@hakimLyon hakimLyon reopened this Oct 16, 2024
Copy link
Member

@kentcdodds kentcdodds left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this! I have a few notes.

@hakimLyon hakimLyon requested a review from kentcdodds October 16, 2024 21:55
@itzmegood
Copy link
Contributor

Will it be possible to have a codemod for this upgrade. Manually upgrading all this for custom/ extended project seems a bit difficult.

@kentcdodds
Copy link
Member

Maybe @jacobparis's tool could help.

@itzmegood
Copy link
Contributor

itzmegood commented Nov 14, 2024

Maybe @jacobparis's tool could help.

I found this https://codemod.com/registry/remix-single-fetch-recipe by jacobparis.
Also curious about your thoughts on switching to biome? (less code/ faster)

@jacobparis
Copy link
Contributor

Maybe @jacobparis's tool could help.

I found this https://codemod.com/registry/remix-single-fetch-recipe by jacobparis. Also curious about your thoughts on switching to biome? (less code/ faster)

I should take that down, it's for an old outdated single fetch API

Remix team is working on some codemods for this now though

@itzmegood
Copy link
Contributor

itzmegood commented Nov 18, 2024

Any update regarding this @kentcdodds , gentle reminder that RR7 was released, so if you wanna revamp, add / switch out some tech like biome or hono or bun feel free to ask =]

@bkilrain
Copy link

I'm in the middle of the same single fetch effort on an app based off this template. I hit some funkiness with how the toasts work for error responses so came over here to see how y'all are handling it.

The new behavior is that loaders don't rerun by default when an action returns a 4xx/5xx response. This means the root loader doesn't process the toast headers until the next GET/successful POST.

@hakimLyon have you noticed if the toasts still work in this case?

@hakimLyon
Copy link
Contributor Author

@hakimLyon have you noticed if the toasts still work in this case?

Hi @bkilrain , I haven’t noticed this behavior on my side. But in Remix Docs about Submission Revalidation Behavior
It suggests using options like shouldRevalidate to customize this behavior and force loaders to rerun if needed.

@bkilrain
Copy link

@hakimLyon have you noticed if the toasts still work in this case?

Hi @bkilrain , I haven’t noticed this behavior on my side. But in Remix Docs about Submission Revalidation Behavior It suggests using options like shouldRevalidate to customize this behavior and force loaders to rerun if needed.

Yep that's what I ended up doing on my side... just raising the possibility that this PR might need it as well.

export const shouldRevalidate: ShouldRevalidateFunction = ({
  defaultShouldRevalidate,
  actionStatus,
}) => {
  const status = String(actionStatus)
  if (status.startsWith('4') || status.startsWith('5')) {
    // 4xx & 5xx error response should be revalidated in case they contain toast headers
    return true
  }
  return defaultShouldRevalidate
}

@kentcdodds
Copy link
Member

Thank you so much for all your contributions to this and the #897 PR! Merged that other one so we're all set!

@kentcdodds kentcdodds closed this Jan 16, 2025
@hakimLyon hakimLyon deleted the v3_singleFetch branch January 17, 2025 20:03
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 this pull request may close these issues.

7 participants