Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@buckett
Copy link
Member

@buckett buckett commented Jun 4, 2025

Currently if the callback function changes then we end up re-loading the token. We shouldn't be doing this because in a functional react component the function might well not be the same between renders.

Currently if the callback function changes then we end up re-loading the token. We shouldn't be doing this because in a functional react component the function might well not be the same between renders.
@buckett buckett requested a review from Copilot June 4, 2025 15:37
@sonarqubecloud
Copy link

sonarqubecloud bot commented Jun 4, 2025

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR updates the token retriever hook so that it only re-fetches when the LTI server URL changes, not when the handleJwt callback identity changes.

  • Removed handleJwt from the useEffect dependency array
  • Locked the effect to rerun exclusively on ltiServer updates
Comments suppressed due to low confidence (1)

src/components/tokenRetriever/LtiTokenRetriever.jsx:71

  • Introduce or update a unit test to assert that fetchToken only runs when ltiServer changes and does not re-run on changes to the handleJwt callback identity.
fetchToken();

As we don't re-fetch upon the function changing this isn't so serious any more, however it's an indication that the component is being mis-used, and so we try to be helpful.
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
C Maintainability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@buckett buckett merged commit fc5473f into master Oct 23, 2025
4 of 5 checks passed
@buckett buckett deleted the reloading-on-render branch October 23, 2025 08:16
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