From 21aa4391dd36e9bac34ad45ca91636656b53a269 Mon Sep 17 00:00:00 2001 From: Eric Giovanola Date: Wed, 17 May 2023 11:22:24 -0700 Subject: [PATCH] Use default params instead of defaultProps --- src/components/TypeaheadMenu/TypeaheadMenu.tsx | 7 +++++-- src/core/Typeahead.tsx | 3 +-- src/core/useTypeahead.ts | 2 +- src/tests/props.ts | 3 --- 4 files changed, 7 insertions(+), 8 deletions(-) delete mode 100644 src/tests/props.ts diff --git a/src/components/TypeaheadMenu/TypeaheadMenu.tsx b/src/components/TypeaheadMenu/TypeaheadMenu.tsx index 59e0cf25..edf6a073 100644 --- a/src/components/TypeaheadMenu/TypeaheadMenu.tsx +++ b/src/components/TypeaheadMenu/TypeaheadMenu.tsx @@ -39,7 +39,10 @@ const propTypes = { renderMenuItemChildren: PropTypes.func, }; -function renderMenuItemChildrenFn(option: Option, props: TypeaheadMenuProps) { +function defaultRenderMenuItemChildren( + option: Option, + props: TypeaheadMenuProps +) { return ( {getOptionLabel(option, props.labelKey)} @@ -53,7 +56,7 @@ const TypeaheadMenu = (props: TypeaheadMenuProps) => { newSelectionPrefix = 'New selection: ', options, paginationText = 'Display additional results...', - renderMenuItemChildren = renderMenuItemChildrenFn, + renderMenuItemChildren = defaultRenderMenuItemChildren, text, ...menuProps } = props; diff --git a/src/core/Typeahead.tsx b/src/core/Typeahead.tsx index a2fe1b06..fae723fb 100644 --- a/src/core/Typeahead.tsx +++ b/src/core/Typeahead.tsx @@ -1,7 +1,7 @@ import PropTypes from 'prop-types'; import React, { forwardRef } from 'react'; -import useTypeahead, { TypeaheadRef, defaultProps } from './useTypeahead'; +import useTypeahead, { TypeaheadRef } from './useTypeahead'; import TypeaheadManager from './TypeaheadManager'; import { @@ -163,6 +163,5 @@ const Typeahead = forwardRef((props, ref) => { // @ts-ignore Typeahead.propTypes = propTypes; -Typeahead.defaultProps = defaultProps; export default Typeahead; diff --git a/src/core/useTypeahead.ts b/src/core/useTypeahead.ts index f9195c09..ad3c4e98 100644 --- a/src/core/useTypeahead.ts +++ b/src/core/useTypeahead.ts @@ -47,7 +47,7 @@ import { import { DEFAULT_LABELKEY } from '../constants'; -export const defaultProps = { +const defaultProps = { allowNew: false, autoFocus: false, caseSensitive: false, diff --git a/src/tests/props.ts b/src/tests/props.ts deleted file mode 100644 index b3793974..00000000 --- a/src/tests/props.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const defaultProps = {}; - -export const defaultState = {};