Fix: unwrap nested data response from React Router#44
Merged
Conversation
…client navigations
Contributor
Greptile OverviewGreptile SummaryThis PR fixes a critical bug where Key Changes:
Impact: Confidence Score: 4/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User as User Loader
participant AuthKit as authkitLoader
participant HandleAuth as handleAuthLoader
participant RR as React Router
User->>AuthKit: Returns data({categories: []})
Note over User: DataWithResponseInit wrapper
AuthKit->>HandleAuth: Passes loader result
alt Loader returns Response
HandleAuth->>RR: Handles as Response
else Loader returns data() wrapper (FIXED)
HandleAuth->>HandleAuth: Check isDataWithResponseInit()
Note over HandleAuth: Unwrap: loaderResult.data
HandleAuth->>HandleAuth: Extract headers from loaderResult.init
HandleAuth->>HandleAuth: Merge data with auth
HandleAuth->>RR: Return data(mergedData, mergedHeaders)
Note over RR: Single level wrapping ✓
else Loader returns plain object
HandleAuth->>HandleAuth: Use loaderResult directly
HandleAuth->>HandleAuth: Merge data with auth
HandleAuth->>RR: Return data(mergedData, headers)
Note over RR: Single level wrapping ✓
end
|
Contributor
Author
|
@nicknisi Not sure who to mention but could someone review and possibly merge this? :) Currently I use a local fork in my app as a temporary workaround but would be nice to see this fixed upstream as well. |
chaance
approved these changes
Dec 12, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR fixes an issue in
authkitLoaderwhere the loader response was wrapped twice in DataWithResponseInit, producing a nested structure that React Router 7 cannot interpret correctly during client-side navigations. The result was that loader data ended up one level too deep, making fields inaccessible and breaking downstream consumers.authkitLoaderinternally wrapped values with data(...) even when the user-supplied loader already returned a data(...) response.The incorrect implementation produced:This may resolve issue #38, as the symptoms described there match the nested data structure, though this has not been explicitly validated.