Skip to content

initial work on clientLoader & clientAction#5543

Closed
jacob-ebey wants to merge 2 commits into
devfrom
client-loader
Closed

initial work on clientLoader & clientAction#5543
jacob-ebey wants to merge 2 commits into
devfrom
client-loader

Conversation

@jacob-ebey

@jacob-ebey jacob-ebey commented Feb 23, 2023

Copy link
Copy Markdown
Member

Closes: #5070

  • Docs
  • Tests

Testing Strategy:

  • new integration tests

@changeset-bot

changeset-bot Bot commented Feb 23, 2023

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: ba3a350

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@brophdawg11 brophdawg11 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

So pumped for this 🤩

Comment thread packages/remix-react/data.ts Outdated
response instanceof Response &&
response.headers.get("X-Remix-Redirect") != null
(response.headers.get("X-Remix-Redirect") != null ||
(response.status >= 300 && response.status < 400))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We can steal this util from RR (or even export it as UNSAFE_ and use it directly:

const redirectStatusCodes = new Set([301, 302, 303, 307, 308]);

export function isRedirectStatusCode(statusCode: number): boolean {
  return redirectStatusCodes.has(statusCode);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is the reason we need this because clientLoader doesn't run through the internal checking? Maybe we can get rid of the need for this an put less in the doFetch...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The reason we need this is because Remix is expecting a 204 response to represent redirects and we don't currently handle real redirect responses.

Comment thread packages/remix-react/routeModules.ts Outdated
export interface ClientDataFunctionArgs {
request: Request;
params: Params;
next: () => Promise<Response | DeferredData | null>;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

We can bikeshed this as we go - I like serverFetch at the moment

Comment on lines +182 to +193
let doFetch = async (request: Request) => {
if (isAction && !route.hasAction) {
let msg =
`Route "${route.id}" does not have an action, but you are trying ` +
`to submit to it. To fix this, please add an \`action\` function to the route`;
console.error(msg);
throw new Error(msg);
} else if (!isAction && !route.hasLoader) {
return null;
}

let result = await fetchData(request, route.id);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if doFetch could stop here so we get all the same error/redirect/catch handling whether they hit the server or not?

Comment thread packages/remix-react/routes.tsx Outdated
@github-actions github-actions Bot added the needs-response We need a response from the original author about this issue/PR label Apr 28, 2023
@remix-run remix-run deleted a comment from github-actions Bot Apr 30, 2023
@machour machour removed the needs-response We need a response from the original author about this issue/PR label Apr 30, 2023
@brophdawg11

Copy link
Copy Markdown
Contributor

I'm gonna close this out for now - we can re-open if needed once we start on v3 features

@brophdawg11 brophdawg11 closed this Aug 2, 2023
@MichaelDeBoey MichaelDeBoey deleted the client-loader branch August 3, 2023 00:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants