rad-ui / ui

Rad UI is an open-source, headless UI component library for building modern, fast, performant, accessible React applications
http://rad-ui.com
MIT License
9 stars 11 forks source link

Improvement: Use optional chaining for conditional rendering. #346

Closed kotAPI closed 5 days ago

kotAPI commented 6 days ago
          **Improvement: Use optional chaining for conditional rendering.**

To avoid potential runtime errors when renderLabel is not provided, use optional chaining.

- {renderLabel && renderLabel(value)}
+ {renderLabel?.(value)}
Committable suggestion > :bangbang: **IMPORTANT** > Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements. `````suggestion {renderLabel?.(value)} `````
Tools
Biome
[error] 39-39: Change to an optional chain. (lint/complexity/useOptionalChain) Unsafe fix: Change to an optional chain.

_Originally posted by @coderabbitai[bot] in https://github.com/rad-ui/ui/pull/343#discussion_r1654601318_