Skip to content

[all components] Tighten render prop warning heuristic - #4324

Merged
atomiks merged 2 commits into
mui:masterfrom
atomiks:codex/fix-render-prop-warning-4314
Mar 13, 2026
Merged

atomiks merged 2 commits into
mui:masterfrom
atomiks:codex/fix-render-prop-warning-4314

Conversation

@atomiks

@atomiks atomiks commented Mar 13, 2026

Copy link
Copy Markdown
Contributor

Fixes #4314

Summary

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

@atomiks atomiks added type: bug It doesn't behave as expected. scope: all components Widespread work has an impact on almost all components. labels Mar 13, 2026
@pkg-pr-new

pkg-pr-new Bot commented Mar 13, 2026 •

Copy link
Copy Markdown
  • base-ui-tanstack-start

  • vite-css-base-ui-example

    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/react@4324
    
    pnpm add https://pkg.pr.new/mui/base-ui/@base-ui/utils@4324
    

commit: 923ffbf

@atomiks
atomiks force-pushed the codex/fix-render-prop-warning-4314 branch from 344b601 to 1c24e6d Compare March 13, 2026 05:35
@netlify

netlify Bot commented Mar 13, 2026

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 344b601
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/69b3a1dbbbf76a00080db346
😎 Deploy Preview https://deploy-preview-4324--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@mui-bot

mui-bot commented Mar 13, 2026 •

Copy link
Copy Markdown

Bundle size report

Bundle Parsed size Gzip size
@base-ui/react 0B(0.00%) 0B(0.00%)

Details of bundle changes


Check out the code infra dashboard for more information about this PR.

@atomiks
atomiks marked this pull request as ready for review March 13, 2026 05:39
@netlify

netlify Bot commented Mar 13, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for base-ui ready!

Name Link
🔨 Latest commit 923ffbf
🔍 Latest deploy log https://app.netlify.com/projects/base-ui/deploys/69b3c9ce7d9ac900088abc63
😎 Deploy Preview https://deploy-preview-4324--base-ui.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@atomiks

atomiks commented Mar 13, 2026

Copy link
Copy Markdown
Contributor Author

Codex Review

Overview

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.

@atomiks
atomiks merged commit d8c529c into mui:master Mar 13, 2026
7 checks passed
@atomiks
atomiks deleted the codex/fix-render-prop-warning-4314 branch March 13, 2026 08:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: all components Widespread work has an impact on almost all components. type: bug It doesn't behave as expected.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[render prop] False positive warning for useCallback render functions inside PascalCase components

3 participants