Skip to content

Commit

Permalink
Replace noop with conditional chaining
Browse files Browse the repository at this point in the history
  • Loading branch information
mirka committed Aug 24, 2022
1 parent 9530a0b commit de963ba
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
6 changes: 2 additions & 4 deletions packages/components/src/tab-panel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import type { TabButtonProps, TabPanelProps } from './types';
import { contextConnect, WordPressComponentProps } from '../ui/context';
import type { ForwardedRef } from 'react';

const noop = () => {};

const TabButton = ( {
tabId,
onClick,
Expand Down Expand Up @@ -48,7 +46,7 @@ function UnconnectedTabPanel(
initialTabName,
orientation = 'horizontal',
activeClass = 'is-active',
onSelect = noop,
onSelect,
}: WordPressComponentProps< TabPanelProps, 'div', false >,
forwardedRef: ForwardedRef< any >
) {
Expand All @@ -57,7 +55,7 @@ function UnconnectedTabPanel(

const handleClick = ( tabKey: string ) => {
setSelected( tabKey );
onSelect( tabKey );
onSelect?.( tabKey );
};

const onNavigate = ( _childIndex: number, child: HTMLButtonElement ) => {
Expand Down
2 changes: 0 additions & 2 deletions packages/components/src/tab-panel/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ export type TabPanelProps = {
/**
* The function called when a tab has been selected.
* It is passed the `tabName` as an argument.
*
* @default `noop`
*/
onSelect?: ( tabName: string ) => void;
/**
Expand Down

0 comments on commit de963ba

Please sign in to comment.