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

fix: call createAppRouter within App component; implement shouldRevalidate for rootLoader sub-route navigation #1256

Merged
merged 9 commits into from
Jan 23, 2025

Conversation

adamstankiewicz
Copy link
Member

@adamstankiewicz adamstankiewicz commented Jan 17, 2025

Description

ENT-9930

It was observed that when replicating an tangentially related issue, there was a brief usage of dispatching an error via NewRelicLoggingService before sending similar error via the expected DatadogLoggingService. This brief usage of NewRelicLoggingService may have caused errant reporting of some errors occurring within the React Router route loaders.

This line was missed during the New Relic -> Datadog migration, and unfortunately getConfig().loggingService(representing DatadogLoggingService) is not available here.

This led to this PR removing the need to call configureLogging or configureAuth for the purpose of the route loaders by moving creation of the above const router = createAppRouter(queryClient) into the rendering of the App, instead of at file import.

The PR also removes a parent Suspense and its fallback component AppSuspenseFallback to make suspense issues more obvious at runtime during development.

For all changes

  • Ensure adequate tests are in place (or reviewed existing tests cover changes)
  • Ensure English strings are marked for translation. See documentation for more details.

Only if submitting a visual change

  • Ensure to attach screenshots
  • Ensure to have UX team confirm screenshots

Copy link

codecov bot commented Jan 17, 2025

Codecov Report

Attention: Patch coverage is 94.73684% with 1 line in your changes missing coverage. Please review.

Project coverage is 89.46%. Comparing base (bc78166) to head (e45969f).
Report is 3 commits behind head on master.

Files with missing lines Patch % Lines
src/routes.tsx 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1256      +/-   ##
==========================================
+ Coverage   89.25%   89.46%   +0.21%     
==========================================
  Files         405      404       -1     
  Lines        8737     8735       -2     
  Branches     2064     2110      +46     
==========================================
+ Hits         7798     7815      +17     
+ Misses        903      884      -19     
  Partials       36       36              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@adamstankiewicz adamstankiewicz marked this pull request as draft January 17, 2025 21:26
@adamstankiewicz adamstankiewicz marked this pull request as ready for review January 22, 2025 14:21
@adamstankiewicz adamstankiewicz changed the title fix: call createAppRouter within App render fix: call createAppRouter within App component; implement shouldRevalidate for rootLoader sub-route navigation Jan 22, 2025
Copy link
Member

@brobro10000 brobro10000 left a comment

Choose a reason for hiding this comment

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

Great job with the ADR. I pulled it down locally to verify and everything seems to be moving alright. 👍🏽

@@ -8,7 +8,7 @@ import { getRoutes } from '../../../routes';
* @param {Object} queryClient React Query query client.
* @returns {Object} React Router browser router.
*/
export default function createAppRouter(queryClient: Types.QueryClient) {
export default function createAppRouter(queryClient: Types.QueryClient): Types.Router {
Copy link
Member

Choose a reason for hiding this comment

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

This defines an expected output type I am guessing?

Copy link
Member Author

Choose a reason for hiding this comment

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

Correct, the added : Types.Router is telling TypeScript the createAppRouter function returns a value with the type Types.Router (which is technically a RemixRouter, same type as returned by createBrowserRouter and createMemoryRouter).

AppProvider: ({ children }) => <div data-testid="app-provider">{children}</div>,
}));

describe('App', () => {
Copy link
Member

Choose a reason for hiding this comment

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

🥳

@adamstankiewicz adamstankiewicz merged commit aea534f into master Jan 23, 2025
6 checks passed
@adamstankiewicz adamstankiewicz deleted the ags/router-fix branch January 23, 2025 19:15
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.

2 participants