bito-code-review[bot] commented on code in PR #39535:
URL: https://github.com/apache/superset/pull/39535#discussion_r3221156727
##########
superset-frontend/packages/superset-ui-core/src/components/AsyncEsmComponent/index.tsx:
##########
@@ -93,7 +99,7 @@ export function AsyncEsmComponent<
// @ts-expect-error -- generic forwardRef has PropsWithoutRef
incompatibility with FullProps
const AsyncComponent: AsyncComponent = forwardRef(function AsyncComponent(
props: FullProps,
- ref,
+ ref: ForwardedRef<ComponentType<FullProps>>,
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Incorrect ref type annotation</b></div>
<div id="fix">
The ref parameter type ForwardedRef<ComponentType<FullProps>> is incorrect
because ComponentType<FullProps> represents the component function type, not
the ref type. The correct type should match the RefAttributes<unknown> in the
AsyncComponent type definition, ensuring type consistency and preventing
potential ref handling issues.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
````suggestion
ref: ForwardedRef<unknown>,
````
</div>
</details>
</div>
<small><i>Code Review Run #1665a5</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
##########
superset-frontend/packages/superset-ui-core/src/components/ModalTrigger/index.tsx:
##########
@@ -84,7 +90,7 @@ export const ModalTrigger = forwardRef(
setShowModal(true);
};
- if (ref) {
+ if (ref && typeof ref !== 'function') {
ref.current = { close, open, showModal }; // eslint-disable-line
}
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Incomplete ref handling</b></div>
<div id="fix">
The ref handling only supports object refs but ignores callback refs, which
can lead to incorrect behavior if a callback ref is passed. React's forwardRef
allows both ref types, so the code should handle both cases.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
````suggestion
if (ref) {
if (typeof ref === 'function') {
ref({ close, open, showModal });
} else {
ref.current = { close, open, showModal }; // eslint-disable-line
}
}
````
</div>
</details>
</div>
<small><i>Code Review Run #1665a5</i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a
href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]