Skip to content

Conversation

@theianmay
Copy link
Member

@theianmay theianmay commented Oct 25, 2025

Motivation

Components defined inside render functions cause React to see a new component type on every render, destroying and recreating the entire subtree's DOM nodes and state.

This was causing:

  • Lint warnings in CI (check_lint job)
  • Unnecessary reconciliation overhead that violates React best practices
  • Could cause issues if these components later add state, effects, or animations

This refactor maintains identical user-facing behavior while fixing the underlying performance and code quality issues.

Description:

  • Extracted [Pointer] component outside [Tooltip] render function with proper TypeScript interface (PointerProps)
  • Extracted [HighlightedButton] component outside [Tooltip] render function with defined prop types (HighlightedButtonProps)
  • Fixed lint warnings: "Do not define components during render" (react/no-unstable-nested-components)
  • Components now receive explicit props instead of relying on closure scope
  • Resolves performance issue where React recreates component types on every render, causing unnecessary reconciliation and DOM remounts

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Jest Unit Test - All 7 existing Tooltip tests pass
  • Checked with example app
  • Lint validation - yarn lint passes with no warnings

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • New and existing unit tests pass locally with my changes

Additional context

- Extracted Pointer component to separate function component with proper TypeScript interface
- Created standalone HighlightedButton component with defined prop types
- Moved components outside of main Tooltip component to reduce nesting and improve readability
- Updated component references to pass required props explicitly
- Added proper TypeScript interfaces for component props (PointerProps, HighlightedButtonProps)
@theianmay theianmay added the component: Tooltip Issue related to Tooltip Component label Oct 25, 2025
@theianmay theianmay self-assigned this Oct 26, 2025
@theianmay theianmay requested a review from Monte9 October 26, 2025 05:20
@theianmay theianmay removed the request for review from Monte9 November 4, 2025 13:41
@theianmay theianmay merged commit f2064d1 into react-native-elements:next Nov 5, 2025
5 checks passed
github-actions bot pushed a commit that referenced this pull request Nov 5, 2025
refactor: extract Tooltip components to resolve ES Lint warnings
github-actions bot pushed a commit that referenced this pull request Nov 5, 2025
refactor: extract Tooltip components to resolve ES Lint warnings
@theianmay theianmay deleted the bugfix/tooltip branch November 5, 2025 05:36
@theianmay theianmay moved this to Closed or Merged 🏁 in Community Roadmap 🛣 Nov 16, 2025
@theianmay theianmay added this to the v5.0.0 milestone Nov 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component: Tooltip Issue related to Tooltip Component

Projects

Status: Closed or Merged 🏁

Development

Successfully merging this pull request may close these issues.

1 participant