IQSS / IQSS/dataverse-frontend

double network calls in React

Open
#871 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
31
Forks
26
Avg merge
4d 13h
Merged PRs (30d)
4

Description

@g-saracca shared with me the following tip for disabling double network calls in React:

% git diff src/index.tsx
diff --git a/src/index.tsx b/src/index.tsx
index 534a26ff..ff2b7fc1 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -4,7 +4,7 @@ import { KcPage } from './keycloak-theme/kc.gen'
 const AppEntrypoint = lazy(() => import('./index.app'))

 createRoot(document.getElementById('root') as HTMLElement).render(
- <StrictMode>
+ <>
     {window.kcContext ? (
       <KcPage kcContext={window.kcContext} />
     ) : (
@@ -12,5 +12,5 @@ createRoot(document.getElementById('root') as HTMLElement).render(
         <AppEntrypoint />
       </Suspense>
     )}
- </StrictMode>
+ </>
 )

This change should not be committed but it's helpful in development to reduce the noise.

We should explain this in the dev guide or make it a config option, if possible.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with src/index.tsx and the provided diff to understand how React StrictMode relates to the development-only double network calls. Then locate the dev guide and decide whether it can explain this behavior, or whether a configuration option is appropriate. Done means the development guidance or supported option clearly addresses the reported noise without requiring the workaround to be committed.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
documentation, frontend
Issue type
Documentation
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.