bito-code-review[bot] commented on code in PR #39451:
URL: https://github.com/apache/superset/pull/39451#discussion_r3518810839
##########
superset-frontend/.storybook/shared/Expandable.tsx:
##########
@@ -17,45 +17,38 @@
* under the License.
*/
-import { Component, ReactNode } from 'react';
+import { useState, useCallback, ReactNode } from 'react';
export type Props = {
children: ReactNode;
expandableWhat?: string;
};
-type State = {
- open: boolean;
-};
-
-export default class Expandable extends Component<Props, State> {
- constructor(props: Props) {
- super(props);
- this.state = { open: false };
- this.handleToggle = this.handleToggle.bind(this);
- }
+export default function Expandable({ children, expandableWhat }: Props) {
+ const [open, setOpen] = useState(false);
- handleToggle() {
- this.setState(({ open }) => ({ open: !open }));
- }
+ const handleToggle = useCallback(() => {
+ setOpen(prevOpen => !prevOpen);
+ }, []);
- render() {
- const { open } = this.state;
- const { children, expandableWhat } = this.props;
+ const label = expandableWhat
+ ? `${open ? 'Hide' : 'Show'} ${expandableWhat}`
+ : open
+ ? 'Hide'
+ : 'Show';
Review Comment:
<!-- Bito Reply -->
The suggestion to use the translation function for labels in this component
is not required, as these labels are intended for development tooling within
Storybook and are not user-facing. You may proceed without applying the
translation function for this specific case.
--
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]