-
-
Notifications
You must be signed in to change notification settings - Fork 10.7k
feat(react-router): Update client middleware to propagate data strategy results up the chain #14151
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
Conversation
🦋 Changeset detectedLatest commit: f2eac66 The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
docs/how-to/middleware.md
Outdated
const results = await next(); | ||
|
||
// Check if we got a 404 from any of our routes | ||
let is404 = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this be simplified to not need to return the results
?
…gy results up the chain (remix-run#14151)
🤖 Hello there, We just published version Thanks! |
🤖 Hello there, We just published version Thanks! |
Currently, we return/bubble nothing in client middlewares because there's no
Response
, but this means you can't do post processing which eliminates one of our primary example use cases of middlewares which is looking up CMS redirects on 404s.Middleware is implemented as part of
dataStrategy
and therefore the expected return value internally is the same thing returned bydataStrategy
(Record<string, DataStrategyResult>
) so it's already public API, so we can just stop purposefully hiding that from userland and bubble it back up (they don't need to use it though). This also has the added benefit of removing another key difference (both in explanation and in implementation) between server and client middleware and makes them almost identical the the only difference being type of thenext
return value.That example CMS use case in the client would now look like this: