You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Fixes a false positive from the invalid-render-prop warning when a valid render callback is wrapped in useCallback inside a PascalCase component.
Before this change, Base UI warned for any render function whose inferred name started with an uppercase letter. In React 19 / Next.js dev builds, callbacks can get inferred names like DropdownMenuExample.useCallback[renderSearchInput], which caused valid render callbacks to be flagged incorrectly.
This PR tightens the heuristic so the warning only fires for names that look like a plain component identifier, while preserving the existing warning for likely render={Component} misuse.
Changes
Restrict the render-prop warning heuristic to plain component-like function names
Avoid warning for inferred names such as DropdownMenuExample.useCallback[renderSearchInput]
Add a regression test covering the useCallback naming pattern
Keep the existing warning behavior for direct uppercase component function
This patch narrows the development-only render warning so it stops flagging valid callbacks whose inferred names include wrapper text like useCallback[...]. It also adds a regression test for that specific case.
Findings (None)
No blocking issues found in this patch.
Confidence: 4/5
High confidence for the changed behavior. I reviewed the full branch diff, checked the warning path and test coverage, and reran the focused useRenderElement test suite. Residual risk is low and mainly limited to unusual function-name shapes outside the covered callback patterns.
Notes
I specifically checked the regex change for robustness. The new pattern is intentionally stricter than the old “starts with uppercase ASCII” check, which is what removes the false positive for names like DropdownMenuExample.useCallback[renderSearchInput].
The allow-list still covers common component-like names, including digits, _, and $ suffixes, so it should behave well for normal authored and transpiled component identifiers.
I did not find a concrete correctness, accessibility, API, maintainability, performance, or test-coverage issue in the branch diff.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4314
Summary
Fixes a false positive from the
invalid-render-propwarning when a valid render callback is wrapped inuseCallbackinside a PascalCase component.Before this change, Base UI warned for any render function whose inferred
namestarted with an uppercase letter. In React 19 / Next.js dev builds, callbacks can get inferred names likeDropdownMenuExample.useCallback[renderSearchInput], which caused valid render callbacks to be flagged incorrectly.This PR tightens the heuristic so the warning only fires for names that look like a plain component identifier, while preserving the existing warning for likely
render={Component}misuse.Changes
DropdownMenuExample.useCallback[renderSearchInput]useCallbacknaming pattern