Skip to content

Refactor Knob component styles for performance - #5416

Open
MaddipatlaChetan24 wants to merge 1 commit into
uber:mainfrom
MaddipatlaChetan24:patch-5
Open

Refactor Knob component styles for performance#5416
MaddipatlaChetan24 wants to merge 1 commit into
uber:mainfrom
MaddipatlaChetan24:patch-5

Conversation

@MaddipatlaChetan24

Copy link
Copy Markdown
Contributor

Fixes #1, Fixes #2

Description

Refactors two style overrides in the Knob component to use static,
module-level objects instead of inline object/function literals that
were being re-created on every render.

  • RadioGroupRoot's style was written as a function
    (({ $theme }) => ({...})) but never actually referenced $theme in
    its return value — it was a constant disguised as a function. Replaced
    with a plain module-level RADIO_GROUP_ROOT_OVERRIDE_STYLE object,
    which baseui's overrides.<Component>.style accepts directly. This
    removes both the per-render function allocation and the function call
    baseui previously had to make to resolve it.
  • The Checkbox's Label override (style: { fontWeight: 500 }) was
    already a static shape but was being re-allocated as a new object
    literal on every render. Hoisted to a module-level
    CHECKBOX_LABEL_OVERRIDE_STYLE constant so the same object reference
    is reused across renders.

Both changes are behavior-identical — same resolved styles, same visual
output — just without the unnecessary re-allocation.

Left the two per-Radio overrides inside the enum options .map()
unchanged. They do use $theme and can't become plain objects, and
while they could in principle also be hoisted to module scope, doing so
risks losing baseui's contextual type inference for the $theme
parameter (which is currently inferred from the JSX prop's expected
type) and could introduce a type error without knowing this project's
exact tsconfig/baseui override type setup. Flagging as a possible
follow-up rather than guessing at a fix that might not compile.

Scope

Patch: Bug Fix

Refactor styles in Knob component to use static objects instead of inline styles, improving performance by avoiding unnecessary re-creation on each render.
@MaddipatlaChetan24

Copy link
Copy Markdown
Contributor Author

can you please check this !!

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