Skip to content

Commit

Permalink
Use default params instead of defaultProps
Browse files Browse the repository at this point in the history
  • Loading branch information
ericgio committed Nov 1, 2023
1 parent 44b9a29 commit 3483ece
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 8 deletions.
7 changes: 5 additions & 2 deletions src/components/TypeaheadMenu/TypeaheadMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ const propTypes = {
renderMenuItemChildren: PropTypes.func,
};

function renderMenuItemChildrenFn(option: Option, props: TypeaheadMenuProps) {
function defaultRenderMenuItemChildren(
option: Option,
props: TypeaheadMenuProps
) {
return (
<Highlighter search={props.text}>
{getOptionLabel(option, props.labelKey)}
Expand All @@ -53,7 +56,7 @@ const TypeaheadMenu = (props: TypeaheadMenuProps) => {
newSelectionPrefix = 'New selection: ',
options,
paginationText = 'Display additional results...',
renderMenuItemChildren = renderMenuItemChildrenFn,
renderMenuItemChildren = defaultRenderMenuItemChildren,
text,
...menuProps
} = props;
Expand Down
3 changes: 1 addition & 2 deletions src/core/Typeahead.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -163,6 +163,5 @@ const Typeahead = forwardRef<TypeaheadRef, Props>((props, ref) => {

// @ts-ignore
Typeahead.propTypes = propTypes;
Typeahead.defaultProps = defaultProps;

export default Typeahead;
2 changes: 1 addition & 1 deletion src/core/useTypeahead.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import {

import { DEFAULT_LABELKEY } from '../constants';

export const defaultProps = {
const defaultProps = {
allowNew: false,
autoFocus: false,
caseSensitive: false,
Expand Down
3 changes: 0 additions & 3 deletions src/tests/props.ts

This file was deleted.

0 comments on commit 3483ece

Please sign in to comment.