Skip to content

fix: move OAuth callback logic to outer AppWrapper component#151

Closed
kshern wants to merge 1 commit into
modelcontextprotocol:mainfrom
kshern:fix/eslint-error
Closed

fix: move OAuth callback logic to outer AppWrapper component#151
kshern wants to merge 1 commit into
modelcontextprotocol:mainfrom
kshern:fix/eslint-error

Conversation

@kshern

@kshern kshern commented Feb 17, 2025

Copy link
Copy Markdown
Contributor
  • Extract OAuth callback logic to improve code organization
  • Fix ESLint error about conditional React Hook usage

Motivation and Context

Fixed ESLint error: "React Hook 'useState' is called conditionally. React Hooks must be called in the exact same order in every component render".

The original implementation had conditional hook calls within the App component due to the OAuth callback logic, which violates React Hooks rules. By extracting the OAuth callback handling to a higher-level AppWrapper component, we ensure hooks are called unconditionally.

How Has This Been Tested?

  • Verified that ESLint no longer reports hook-related errors
  • Confirmed that the main application renders correctly

Breaking Changes

No breaking changes. This is an internal refactoring that does not affect the external API or user experience.

Types of changes

  • [✓] Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • [✓] I have read the MCP Documentation
  • [✓] My code follows the repository's style guidelines
  • [✓] New and existing tests pass locally (no new lint errors introduced)
  • [✓] I have added appropriate error handling
  • [✓] I have added or updated documentation as needed

Additional context

The refactoring ensures React Hooks are called unconditionally and in the same order by:

  1. Moving route-specific logic to a wrapper component
  2. Keeping the App component's hook calls consistent

@kshern kshern closed this Feb 19, 2025
@kshern kshern deleted the fix/eslint-error branch February 24, 2025 06:17
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.

1 participant