Skip to content

Remove memoization of buildMenuOptions #4388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/beige-eagles-jog.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-select": patch
---

Removed memoization of buildMenuOptions
26 changes: 2 additions & 24 deletions packages/react-select/src/Select.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// @flow

import React, { Component, type ElementRef, type Node } from 'react';
import memoizeOne from 'memoize-one';
import { MenuPlacer } from './components/Menu';

import { createFilter } from './filters';
Expand Down Expand Up @@ -978,33 +977,12 @@ export default class Select extends Component<Props, State> {
return defaultComponents(this.props);
};

buildCategorizedOptionsFromPropsAndSelectValue = memoizeOne(
buildCategorizedOptions,
(newArgs: any, lastArgs: any) => {
const [newProps, newSelectValue] = (newArgs: [Props, OptionsType]);
const [lastProps, lastSelectValue] = (lastArgs: [Props, OptionsType]);

return (
newSelectValue === lastSelectValue &&
newProps.inputValue === lastProps.inputValue &&
newProps.options === lastProps.options
);
}
);
buildCategorizedOptions = () =>
this.buildCategorizedOptionsFromPropsAndSelectValue(
this.props,
this.state.selectValue
);
buildCategorizedOptions(this.props, this.state.selectValue);
getCategorizedOptions = () =>
this.props.menuIsOpen ? this.buildCategorizedOptions() : [];
buildFocusableOptionsFromCategorizedOptions = memoizeOne(
buildFocusableOptionsFromCategorizedOptions
);
buildFocusableOptions = () =>
this.buildFocusableOptionsFromCategorizedOptions(
this.buildCategorizedOptions()
);
buildFocusableOptionsFromCategorizedOptions(this.buildCategorizedOptions());
getFocusableOptions = () =>
this.props.menuIsOpen ? this.buildFocusableOptions() : [];

Expand Down