Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

Commit

Permalink
fix(core): call generateAutocompleteId only if necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
francoischalifour committed Feb 12, 2020
1 parent c647224 commit ce4d496
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/autocomplete-core/defaultProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export function getDefaultProps<TItem>(
: {}) as typeof window;

return {
id: generateAutocompleteId(),
minLength: 1,
placeholder: '',
autoFocus: false,
Expand All @@ -27,6 +26,9 @@ export function getDefaultProps<TItem>(
onStateChange: noop,
onSubmit: noop,
...props,
// Since `generateAutocompleteId` triggers a side effect (it increments
// and internal counter), we don't want to execute it if unnecessary.
id: props.id ?? generateAutocompleteId(),
// The following props need to be deeply defaulted.
initialState: {
highlightedIndex: 0,
Expand Down

0 comments on commit ce4d496

Please sign in to comment.