Skip to content

Export useIsTooltipActive and useActiveTooltipCoordinate hooks hooks#6880

Merged
ckifer merged 1 commit intomainfrom
tooltip-hooks
Jan 13, 2026
Merged

Export useIsTooltipActive and useActiveTooltipCoordinate hooks hooks#6880
ckifer merged 1 commit intomainfrom
tooltip-hooks

Conversation

@PavelVanecek
Copy link
Collaborator

@PavelVanecek PavelVanecek commented Jan 13, 2026

Related Issue

Closes #6299

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)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • I have added a storybook story or VR test, or extended an existing story or VR test to show my changes

Summary by CodeRabbit

  • New Features

    • Introduced two new hooks: useIsTooltipActive() to check tooltip activation state and useActiveTooltipCoordinate() to access tooltip coordinates.
  • Documentation

    • Added comprehensive API documentation and interactive examples for the new tooltip hooks.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 13, 2026

Walkthrough

The PR introduces two new public hooks (useIsTooltipActive and useActiveTooltipCoordinate) to expose tooltip state and coordinates from Redux selectors. It narrows the coordinate type from Coordinate | PolarCoordinate | undefined to Coordinate | undefined across the tooltip system and adds documentation and examples for the new hooks.

Changes

Cohort / File(s) Summary
Core Hook Exports
src/hooks.ts, src/index.ts
Added two new public hooks: useIsTooltipActive() returning boolean and useActiveTooltipCoordinate() returning Coordinate | undefined. These hooks read from tooltip selectors and normalize the data for public consumption.
Type Narrowing - Selectors & State
src/state/selectors/selectors.ts, src/state/tooltipSlice.ts, src/component/Tooltip.tsx, src/synchronisation/useChartSynchronisation.tsx
Narrowed coordinate types from Coordinate | PolarCoordinate | undefined to Coordinate | undefined and replaced ChartCoordinate with Coordinate in function signatures. Removed PolarCoordinate imports where no longer needed.
Test Updates
omnidoc/readProject.spec.ts
Replaced full inline snapshot assertion for Variable symbol filtering with targeted containment checks for "Area" and "Bar" exports.
Documentation Files
www/src/docs/api/useIsTooltipActiveAPI.tsx, www/src/docs/api/useActiveTooltipCoordinateAPI.tsx, www/src/docs/apiCates.ts, www/src/docs/api/index.ts
Added new API documentation objects describing the two new hooks, their return types, and usage context. Updated API categories to include the new hooks.
Example Files
www/src/docs/apiExamples/useIsTooltipActive/index.ts, www/src/docs/apiExamples/useActiveTooltipCoordinate/index.ts, www/src/docs/apiExamples/index.tsx
Added example groups for both new hooks with LineChartExample references and metadata.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

typescript

Suggested reviewers

  • ckifer
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: exporting two new hooks for tooltip functionality.
Description check ✅ Passed The description is mostly complete, includes the related issue, identifies the change type as a new feature, and documents the completed checklist items about documentation updates.
Linked Issues check ✅ Passed All coding requirements from issue #6299 are met: hooks expose tooltip cursor x/y coordinates via useActiveTooltipCoordinate and active state via useIsTooltipActive, with documentation added.
Out of Scope Changes check ✅ Passed All changes are focused on implementing the two tooltip hooks and their documentation; no unrelated modifications to core logic or unrelated features are present.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/state/selectors/selectors.ts (1)

146-159: Fix the return type annotation to match the actual implementation.

The return type is annotated as Coordinate | undefined, but the implementation can return PolarCoordinate. Since tooltipInteractionState.coordinate is typed as Coordinate | PolarCoordinate | undefined, and the nullish coalescing operator returns it unchanged when it's not null/undefined, the selector can return a PolarCoordinate at runtime despite the narrower type annotation.

The return type should be Coordinate | PolarCoordinate | undefined to match the possible values from tooltipInteractionState.coordinate.

🧹 Nitpick comments (2)
www/src/docs/api/index.ts (1)

74-75: Remove explicit .tsx file extensions from imports.

The imports include explicit .tsx extensions which is non-standard for TypeScript module imports. Most bundlers and TypeScript configurations expect extension-less imports.

Suggested fix
-import { useActiveTooltipCoordinateAPI } from './useActiveTooltipCoordinateAPI.tsx';
-import { useIsTooltipActiveAPI } from './useIsTooltipActiveAPI.tsx';
+import { useActiveTooltipCoordinateAPI } from './useActiveTooltipCoordinateAPI';
+import { useIsTooltipActiveAPI } from './useIsTooltipActiveAPI';
src/hooks.ts (1)

137-157: Consider memoizing the returned coordinate object.

The hook creates a new object reference on every call, which could trigger unnecessary re-renders for consumers who use this in dependency arrays or perform shallow equality checks. The explicit { x, y } extraction is correct for stripping PolarCoordinate properties from the internal state.

♻️ Optional: memoize the coordinate to preserve referential equality
+import { useMemo } from 'react';
+
 export const useActiveTooltipCoordinate = (): Coordinate | undefined => {
   const coordinate = useAppSelector(selectActiveTooltipCoordinate);
-  if (coordinate == null) {
-    return undefined;
-  }
-  return {
-    x: coordinate.x,
-    y: coordinate.y,
-  };
+  return useMemo(() => {
+    if (coordinate == null) {
+      return undefined;
+    }
+    return {
+      x: coordinate.x,
+      y: coordinate.y,
+    };
+  }, [coordinate?.x, coordinate?.y]);
 };
📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9bd3552 and 5baa003.

⛔ Files ignored due to path filters (1)
  • www/test/__snapshots__/navigation.spec.tsx.snap is excluded by !**/*.snap
📒 Files selected for processing (14)
  • omnidoc/readProject.spec.ts
  • src/component/Tooltip.tsx
  • src/hooks.ts
  • src/index.ts
  • src/state/selectors/selectors.ts
  • src/state/tooltipSlice.ts
  • src/synchronisation/useChartSynchronisation.tsx
  • www/src/docs/api/index.ts
  • www/src/docs/api/useActiveTooltipCoordinateAPI.tsx
  • www/src/docs/api/useIsTooltipActiveAPI.tsx
  • www/src/docs/apiCates.ts
  • www/src/docs/apiExamples/index.tsx
  • www/src/docs/apiExamples/useActiveTooltipCoordinate/index.ts
  • www/src/docs/apiExamples/useIsTooltipActive/index.ts
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

**/*.{ts,tsx}: Never use any type (implicit or explicit) in TypeScript code
Prefer unknown over any and refine the type in TypeScript
Type function parameters and return values explicitly in TypeScript, do not rely on implicit any or inference; exceptions are React components and trivial functions
Do not use as type assertions in TypeScript; the only exception is as const

All imports from recharts must use the public API entry point (e.g., import { TooltipIndex } from 'recharts'). Imports from internal paths like recharts/types/* or recharts/src/* are not allowed and will fail the linter.

Files:

  • src/index.ts
  • omnidoc/readProject.spec.ts
  • www/src/docs/apiExamples/index.tsx
  • www/src/docs/apiExamples/useIsTooltipActive/index.ts
  • www/src/docs/api/useIsTooltipActiveAPI.tsx
  • www/src/docs/api/useActiveTooltipCoordinateAPI.tsx
  • src/synchronisation/useChartSynchronisation.tsx
  • www/src/docs/apiExamples/useActiveTooltipCoordinate/index.ts
  • src/component/Tooltip.tsx
  • src/state/tooltipSlice.ts
  • www/src/docs/apiCates.ts
  • www/src/docs/api/index.ts
  • src/state/selectors/selectors.ts
  • src/hooks.ts
**/*.{js,ts,tsx}

📄 CodeRabbit inference engine (CONTRIBUTING.md)

Ensure code lints by running npm run lint and follows Airbnb's Style Guide

Files:

  • src/index.ts
  • omnidoc/readProject.spec.ts
  • www/src/docs/apiExamples/index.tsx
  • www/src/docs/apiExamples/useIsTooltipActive/index.ts
  • www/src/docs/api/useIsTooltipActiveAPI.tsx
  • www/src/docs/api/useActiveTooltipCoordinateAPI.tsx
  • src/synchronisation/useChartSynchronisation.tsx
  • www/src/docs/apiExamples/useActiveTooltipCoordinate/index.ts
  • src/component/Tooltip.tsx
  • src/state/tooltipSlice.ts
  • www/src/docs/apiCates.ts
  • www/src/docs/api/index.ts
  • src/state/selectors/selectors.ts
  • src/hooks.ts
src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Do not hardcode any strings or formatting choices in library code; users should provide localized strings as desired

Files:

  • src/index.ts
  • src/synchronisation/useChartSynchronisation.tsx
  • src/component/Tooltip.tsx
  • src/state/tooltipSlice.ts
  • src/state/selectors/selectors.ts
  • src/hooks.ts
**/*.spec.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

When running unit tests, prefer to run a single test file using npm run test -- path/to/TestFile.spec.tsx rather than running all tests with npm test

Unit tests should be placed in the test directory, with some tests also allowed in www/test. Test files follow the naming convention *.spec.tsx.

Files:

  • omnidoc/readProject.spec.ts
🧠 Learnings (12)
📓 Common learnings
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6669
File: www/src/docs/exampleComponents/ScatterChart/ScatterChartWithLabels.tsx:2-2
Timestamp: 2025-11-23T13:30:10.395Z
Learning: The `TooltipIndex` type from recharts is defined in `src/state/tooltipSlice.ts` but is not currently exported from the public API entry points. It should not be imported from `recharts/types/state/tooltipSlice` as this is an internal implementation path. An ESLint rule is needed to prevent regressions.
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6771
File: src/shape/Curve.tsx:39-40
Timestamp: 2025-12-14T13:58:58.361Z
Learning: In the recharts codebase, `useAppSelector` and hooks like `useChartLayout()` are designed to return `undefined` when used outside Redux Provider context, rather than throwing errors. This allows components like `Curve` that call these hooks to work standalone by falling back to prop values.
📚 Learning: 2025-11-23T13:30:10.395Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6669
File: www/src/docs/exampleComponents/ScatterChart/ScatterChartWithLabels.tsx:2-2
Timestamp: 2025-11-23T13:30:10.395Z
Learning: The `TooltipIndex` type from recharts is defined in `src/state/tooltipSlice.ts` but is not currently exported from the public API entry points. It should not be imported from `recharts/types/state/tooltipSlice` as this is an internal implementation path. An ESLint rule is needed to prevent regressions.

Applied to files:

  • src/index.ts
  • www/src/docs/apiExamples/index.tsx
  • www/src/docs/apiExamples/useIsTooltipActive/index.ts
  • www/src/docs/api/useIsTooltipActiveAPI.tsx
  • www/src/docs/api/useActiveTooltipCoordinateAPI.tsx
  • src/synchronisation/useChartSynchronisation.tsx
  • www/src/docs/apiExamples/useActiveTooltipCoordinate/index.ts
  • src/component/Tooltip.tsx
  • src/state/tooltipSlice.ts
  • www/src/docs/apiCates.ts
  • www/src/docs/api/index.ts
  • src/state/selectors/selectors.ts
  • src/hooks.ts
📚 Learning: 2025-12-26T15:59:11.254Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: DEVELOPING.md:0-0
Timestamp: 2025-12-26T15:59:11.254Z
Learning: Applies to **/*.{ts,tsx} : All imports from `recharts` must use the public API entry point (e.g., `import { TooltipIndex } from 'recharts'`). Imports from internal paths like `recharts/types/*` or `recharts/src/*` are not allowed and will fail the linter.

Applied to files:

  • src/index.ts
  • www/src/docs/apiExamples/index.tsx
  • www/src/docs/apiExamples/useIsTooltipActive/index.ts
  • www/src/docs/api/useIsTooltipActiveAPI.tsx
  • www/src/docs/api/useActiveTooltipCoordinateAPI.tsx
  • src/synchronisation/useChartSynchronisation.tsx
  • www/src/docs/apiExamples/useActiveTooltipCoordinate/index.ts
  • src/component/Tooltip.tsx
  • www/src/docs/api/index.ts
  • src/hooks.ts
📚 Learning: 2025-11-25T01:23:08.250Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: test/README.md:0-0
Timestamp: 2025-11-25T01:23:08.250Z
Learning: Applies to test/**/*.{test,spec}.{ts,tsx} : When testing tooltips on hover, use `vi.runOnlyPendingTimers()` after each `userEvent.hover()` call or use the `showTooltip` helper function from `tooltipTestHelpers.ts` to account for requestAnimationFrame delays

Applied to files:

  • src/index.ts
  • www/src/docs/apiExamples/index.tsx
  • www/src/docs/apiExamples/useIsTooltipActive/index.ts
  • www/src/docs/api/useActiveTooltipCoordinateAPI.tsx
  • www/src/docs/apiExamples/useActiveTooltipCoordinate/index.ts
  • src/component/Tooltip.tsx
  • www/src/docs/api/index.ts
  • src/hooks.ts
📚 Learning: 2025-12-14T13:58:58.361Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6771
File: src/shape/Curve.tsx:39-40
Timestamp: 2025-12-14T13:58:58.361Z
Learning: In the recharts codebase, `useAppSelector` and hooks like `useChartLayout()` are designed to return `undefined` when used outside Redux Provider context, rather than throwing errors. This allows components like `Curve` that call these hooks to work standalone by falling back to prop values.

Applied to files:

  • src/index.ts
  • www/src/docs/api/useIsTooltipActiveAPI.tsx
  • www/src/docs/api/useActiveTooltipCoordinateAPI.tsx
  • src/hooks.ts
📚 Learning: 2025-12-26T15:59:11.254Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: DEVELOPING.md:0-0
Timestamp: 2025-12-26T15:59:11.254Z
Learning: Applies to test-vr/**/*.spec.ts : Visual regression tests should follow the naming convention `*.spec.ts` and be placed in the `test-vr` directory. When updating snapshots, new files created in `test-vr/__snapshots__` should be committed to the repository.

Applied to files:

  • omnidoc/readProject.spec.ts
📚 Learning: 2025-11-25T01:23:08.250Z
Learnt from: CR
Repo: recharts/recharts PR: 0
File: test/README.md:0-0
Timestamp: 2025-11-25T01:23:08.250Z
Learning: Applies to test/**/*.{test,spec}.{ts,tsx} : Verify the number of selector calls using the spy object from `createSelectorTestCase` to spot unnecessary re-renders and improve performance

Applied to files:

  • omnidoc/readProject.spec.ts
📚 Learning: 2025-12-16T08:12:13.355Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6783
File: test/util/ChartUtils.spec.tsx:15-16
Timestamp: 2025-12-16T08:12:13.355Z
Learning: In the recharts codebase, files in the `test` folder are allowed to import from internal paths (e.g., `../../src/state/cartesianAxisSlice`) and do not need to use the public API entry point (`src/index.ts`). The public API import restriction applies only to non-test code.

Applied to files:

  • www/src/docs/apiExamples/index.tsx
  • www/src/docs/apiExamples/useIsTooltipActive/index.ts
  • www/src/docs/api/useActiveTooltipCoordinateAPI.tsx
  • www/src/docs/apiExamples/useActiveTooltipCoordinate/index.ts
  • src/component/Tooltip.tsx
  • www/src/docs/api/index.ts
  • src/hooks.ts
📚 Learning: 2026-01-06T22:33:55.414Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6855
File: www/src/docs/api/AreaChartAPI.tsx:422-438
Timestamp: 2026-01-06T22:33:55.414Z
Learning: In Recharts v3, components can render inside any chart type as long as the parent provides the necessary cartesian context (e.g., AreaChart, BarChart, ComposedChart, LineChart, ScatterChart). This means API/tests describing cross-chart compatibility should reflect that Funnel-like components can render under multiple chart parents when Cartesian context is available. When reviewing code or docs, verify that the parent chart supplies the required context and that embedding is intentional for all relevant chart types; update tests/docs to avoid assuming stricter parent-child limitations from Recharts v2.

Applied to files:

  • www/src/docs/api/useIsTooltipActiveAPI.tsx
  • www/src/docs/api/useActiveTooltipCoordinateAPI.tsx
📚 Learning: 2026-01-11T06:13:55.304Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6869
File: www/src/docs/api/useXAxisDomainAPI.tsx:6-20
Timestamp: 2026-01-11T06:13:55.304Z
Learning: In API documentation for hooks (e.g., useXAxisDomainAPI), it's acceptable to describe a parameter like xAxisId using both its literal value (0) and the constant name (defaultAxisId). The description can reference the literal to aid readability, while the defaultVal or equivalent should point to the constant name to aid maintainability. Ensure consistency across similar docs and clearly explain both perspectives for developers using the API.

Applied to files:

  • www/src/docs/api/useIsTooltipActiveAPI.tsx
  • www/src/docs/api/useActiveTooltipCoordinateAPI.tsx
📚 Learning: 2025-12-14T13:58:49.197Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6771
File: src/shape/Curve.tsx:39-40
Timestamp: 2025-12-14T13:58:49.197Z
Learning: In the recharts codebase, hooks like useAppSelector and other hooks (e.g., useChartLayout()) return undefined when used outside Redux Provider context, instead of throwing. This enables components that call these hooks, such as Curve, to operate in standalone mode by falling back to prop values. During code reviews, ensure TSX files gracefully handle undefined results from hooks and implement fallbacks (e.g., via default props or explicit prop-based values) rather than assuming the hook is always within Provider.

Applied to files:

  • src/synchronisation/useChartSynchronisation.tsx
  • src/component/Tooltip.tsx
📚 Learning: 2026-01-11T06:14:03.412Z
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6869
File: www/src/docs/api/useXAxisDomainAPI.tsx:6-20
Timestamp: 2026-01-11T06:14:03.412Z
Learning: In Recharts, the constant `defaultAxisId` equals `0`. When documenting hook parameters like `xAxisId` in API docs, it's acceptable for the description to reference the literal value (0) while the `defaultVal` field references the constant name ('defaultAxisId'), as both perspectives are useful for users.

Applied to files:

  • src/hooks.ts
🧬 Code graph analysis (11)
www/src/docs/apiExamples/index.tsx (2)
www/src/docs/apiExamples/useIsTooltipActive/index.ts (1)
  • useIsTooltipActiveApiExamples (5-13)
www/src/docs/apiExamples/useActiveTooltipCoordinate/index.ts (1)
  • useActiveTooltipCoordinateApiExamples (5-13)
www/src/docs/apiExamples/useIsTooltipActive/index.ts (1)
www/src/docs/exampleComponents/types.ts (1)
  • ChartExample (3-25)
www/src/docs/api/useIsTooltipActiveAPI.tsx (1)
www/src/docs/api/types.ts (1)
  • ApiDoc (21-31)
www/src/docs/api/useActiveTooltipCoordinateAPI.tsx (1)
www/src/docs/api/types.ts (1)
  • ApiDoc (21-31)
src/synchronisation/useChartSynchronisation.tsx (1)
src/index.ts (1)
  • Coordinate (138-138)
www/src/docs/apiExamples/useActiveTooltipCoordinate/index.ts (1)
www/src/docs/exampleComponents/types.ts (1)
  • ChartExample (3-25)
src/component/Tooltip.tsx (2)
src/util/types.ts (1)
  • Coordinate (128-131)
src/state/hooks.ts (1)
  • useAppSelector (40-62)
src/state/tooltipSlice.ts (2)
src/index.ts (1)
  • Coordinate (138-138)
src/util/types.ts (1)
  • Coordinate (128-131)
www/src/docs/api/index.ts (2)
www/src/docs/api/useIsTooltipActiveAPI.tsx (1)
  • useIsTooltipActiveAPI (4-30)
www/src/docs/api/useActiveTooltipCoordinateAPI.tsx (1)
  • useActiveTooltipCoordinateAPI (4-31)
src/state/selectors/selectors.ts (3)
src/index.ts (1)
  • Coordinate (138-138)
src/util/types.ts (1)
  • Coordinate (128-131)
src/state/tooltipSlice.ts (1)
  • TooltipInteractionState (130-174)
src/hooks.ts (2)
src/state/selectors/tooltipSelectors.ts (2)
  • selectIsTooltipActive (493-496)
  • selectActiveTooltipCoordinate (479-491)
src/util/types.ts (1)
  • Coordinate (128-131)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Build, Test, Pack
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (14)
src/component/Tooltip.tsx (1)

14-14: LGTM! Type narrowing from Coordinate | PolarCoordinate to Coordinate is consistent with the PR objectives.

The removal of PolarCoordinate from the import and the narrowed type annotation for coordinate aligns with the broader changes in this PR to simplify the public API. The Coordinate type with x and y properties is sufficient for the tooltip cursor coordinates being exposed via the new hooks.

Also applies to: 332-334

omnidoc/readProject.spec.ts (1)

44-50: LGTM! Test refactoring improves maintainability.

Replacing the inline snapshot with targeted assertions makes this test less brittle. As the public API expands (like with the new tooltip hooks in this PR), the test won't need constant snapshot updates while still verifying the core behavior of symbol kind filtering.

www/src/docs/apiCates.ts (1)

27-28: LGTM! New hooks properly categorized.

The placement of useIsTooltipActive and useActiveTooltipCoordinate in the general-components category is appropriate, grouping them with other tooltip-related items and hooks.

www/src/docs/apiExamples/index.tsx (1)

35-36: LGTM! API examples properly registered.

The imports and map entries follow the established pattern in this file. The hook names used as keys are consistent with their usage in apiCates.ts and the API documentation.

Also applies to: 64-65

www/src/docs/api/useIsTooltipActiveAPI.tsx (1)

4-30: Update documentation version claim — Recharts v3.7 does not exist.

Line 18 claims the hook is "Available since Recharts 3.7", but v3.7 has not been released. The latest Recharts version is v3.6.0, and this hook is not present in that release. Since the hook was only recently added to the codebase and is not yet in any published version, the version reference should be removed or updated once the actual release version is finalized. Until then, either remove the version statement or mark it as "Available in upcoming release".

The API documentation structure and descriptions are otherwise accurate.

⛔ Skipped due to learnings
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6669
File: www/src/docs/exampleComponents/ScatterChart/ScatterChartWithLabels.tsx:2-2
Timestamp: 2025-11-23T13:30:10.395Z
Learning: The `TooltipIndex` type from recharts is defined in `src/state/tooltipSlice.ts` but is not currently exported from the public API entry points. It should not be imported from `recharts/types/state/tooltipSlice` as this is an internal implementation path. An ESLint rule is needed to prevent regressions.
Learnt from: CR
Repo: recharts/recharts PR: 0
File: DEVELOPING.md:0-0
Timestamp: 2025-12-26T15:59:11.254Z
Learning: Applies to **/*.{ts,tsx} : All imports from `recharts` must use the public API entry point (e.g., `import { TooltipIndex } from 'recharts'`). Imports from internal paths like `recharts/types/*` or `recharts/src/*` are not allowed and will fail the linter.
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6869
File: www/src/docs/api/useXAxisDomainAPI.tsx:6-20
Timestamp: 2026-01-11T06:14:03.412Z
Learning: In Recharts, the constant `defaultAxisId` equals `0`. When documenting hook parameters like `xAxisId` in API docs, it's acceptable for the description to reference the literal value (0) while the `defaultVal` field references the constant name ('defaultAxisId'), as both perspectives are useful for users.
Learnt from: PavelVanecek
Repo: recharts/recharts PR: 6659
File: www/src/components/GuideView/Performance/index.tsx:232-250
Timestamp: 2025-11-19T14:08:01.728Z
Learning: In Recharts version 3.4.2, object-as-prop optimizations were introduced to reduce unnecessary re-renders when new object references are passed as props. This affects the recommendation for the `react-perf/jsx-no-new-object-as-prop` ESLint rule.
Learnt from: CR
Repo: recharts/recharts PR: 0
File: test/README.md:0-0
Timestamp: 2025-11-25T01:23:08.250Z
Learning: Applies to test/**/*.{test,spec}.{ts,tsx} : When testing tooltips on hover, use `vi.runOnlyPendingTimers()` after each `userEvent.hover()` call or use the `showTooltip` helper function from `tooltipTestHelpers.ts` to account for requestAnimationFrame delays
www/src/docs/apiExamples/useIsTooltipActive/index.ts (1)

1-13: LGTM!

The API examples file is correctly structured with proper typing and follows the established pattern for chart examples. The ReadonlyArray<ChartExample> type ensures immutability, and all required fields from the ChartExample type are provided.

www/src/docs/apiExamples/useActiveTooltipCoordinate/index.ts (1)

1-13: LGTM!

The file follows the same well-structured pattern as the useIsTooltipActive examples, with consistent typing and proper configuration for the devtools tab.

www/src/docs/api/index.ts (1)

110-113: LGTM!

The new API documentation entries are well-organized, grouping all tooltip-related hooks together (useIsTooltipActive, useActiveTooltipDataPoints, useActiveTooltipLabel, useActiveTooltipCoordinate).

www/src/docs/api/useActiveTooltipCoordinateAPI.tsx (1)

1-31: LGTM!

The API documentation is well-structured and provides clear information about the hook's behavior, return type, and usage constraints. The return type Coordinate | undefined correctly matches the narrowed type in the selector implementation.

src/state/selectors/selectors.ts (1)

18-25: LGTM on import retention.

The PolarCoordinate import is correctly retained as it's still used internally in combineActivePolarProps (line 254), even though it's been removed from the public API surface of selectActiveCoordinate.

src/state/tooltipSlice.ts (1)

83-86: Type narrowing is appropriate for public API simplification.

The narrowing of activeCoordinate from Coordinate | PolarCoordinate | undefined to Coordinate | undefined simplifies the public API. Internal state (TooltipInteractionState.coordinate at line 173) still retains PolarCoordinate support, allowing internal flexibility while presenting a cleaner interface to consumers.

src/synchronisation/useChartSynchronisation.tsx (1)

9-9: Type alignment with the broader coordinate type narrowing.

The import change and parameter type update from ChartCoordinate to Coordinate are consistent with the type narrowing applied across the tooltip system in this PR.

Also applies to: 197-204

src/index.ts (1)

155-164: Public API exports correctly expose the new tooltip hooks.

The new hooks useIsTooltipActive and useActiveTooltipCoordinate are properly exported alongside existing hooks, fulfilling the linked issue #6299's request for hook-based access to tooltip state.

src/hooks.ts (1)

122-135: Well-documented hook with appropriate defensive coding.

The ?? false fallback correctly handles the case when useAppSelector returns undefined outside Redux Provider context, which aligns with the established pattern in this codebase (based on learnings).

@codecov
Copy link

codecov bot commented Jan 13, 2026

Codecov Report

❌ Patch coverage is 88.88889% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.26%. Comparing base (9bd3552) to head (5baa003).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
src/hooks.ts 21.42% 11 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6880      +/-   ##
==========================================
- Coverage   94.27%   94.26%   -0.02%     
==========================================
  Files         561      565       +4     
  Lines       53641    53735      +94     
  Branches     5178     5178              
==========================================
+ Hits        50571    50654      +83     
- Misses       3061     3072      +11     
  Partials        9        9              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions
Copy link
Contributor

Staging Deployment Details

These deployments will remain available for 30 days.

To update snapshots: Comment /update-snapshots on this PR to automatically update the baseline screenshots.

@codecov
Copy link

codecov bot commented Jan 13, 2026

Bundle Report

Changes will increase total bundle size by 3.55kB (0.13%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
recharts/bundle-cjs 1.21MB 1.91kB (0.16%) ⬆️
recharts/bundle-es6 1.04MB 1.48kB (0.14%) ⬆️
recharts/bundle-umd 529.04kB 168 bytes (0.03%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: recharts/bundle-es6

Assets Changed:

Asset Name Size Change Total Size Change (%)
hooks.js 1.43kB 6.23kB 29.77% ⚠️
index.js 48 bytes 3.38kB 1.44%
view changes for bundle: recharts/bundle-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
index.js 306 bytes 12.18kB 2.58%
hooks.js 1.6kB 7.25kB 28.38% ⚠️
view changes for bundle: recharts/bundle-umd

Assets Changed:

Asset Name Size Change Total Size Change (%)
Recharts.js 168 bytes 529.04kB 0.03%

Comment on lines +127 to +128
* Recharts only allows one Tooltip per chart, so this hook does not take any parameters.
* Weird things may happen if you have multiple Tooltip components in the same chart so please don't do that.
Copy link
Member

Choose a reason for hiding this comment

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

I mean technically we allow this in 3.x?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The state internally only stores a single instance so the tooltips will overwrite each other randomly. So technically it's possible but also not supported.

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.

Missing cursor coordinate and active tooltip state - ideally from a hook

2 participants