mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Remove memoize-one from grafana-ui (#75016)
This commit is contained in:
parent
64dd8df441
commit
7b4536cb2f
@ -76,7 +76,6 @@
|
|||||||
"is-hotkey": "0.2.0",
|
"is-hotkey": "0.2.0",
|
||||||
"jquery": "3.7.0",
|
"jquery": "3.7.0",
|
||||||
"lodash": "4.17.21",
|
"lodash": "4.17.21",
|
||||||
"memoize-one": "6.0.0",
|
|
||||||
"micro-memoize": "^4.1.2",
|
"micro-memoize": "^4.1.2",
|
||||||
"moment": "2.29.4",
|
"moment": "2.29.4",
|
||||||
"monaco-editor": "0.34.0",
|
"monaco-editor": "0.34.0",
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { css } from '@emotion/css';
|
import { css } from '@emotion/css';
|
||||||
import memoizeOne from 'memoize-one';
|
import memoize from 'micro-memoize';
|
||||||
import RCCascader from 'rc-cascader';
|
import RCCascader from 'rc-cascader';
|
||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
|
|
||||||
@ -106,7 +106,7 @@ export class Cascader extends PureComponent<CascaderProps, CascaderState> {
|
|||||||
return selectOptions;
|
return selectOptions;
|
||||||
};
|
};
|
||||||
|
|
||||||
getSearchableOptions = memoizeOne((options: CascaderOption[]) => this.flattenOptions(options));
|
getSearchableOptions = memoize((options: CascaderOption[]) => this.flattenOptions(options));
|
||||||
|
|
||||||
setInitialValue(searchableOptions: Array<SelectableValue<string[]>>, initValue?: string) {
|
setInitialValue(searchableOptions: Array<SelectableValue<string[]>>, initValue?: string) {
|
||||||
if (!initValue) {
|
if (!initValue) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Property } from 'csstype';
|
import { Property } from 'csstype';
|
||||||
import { clone } from 'lodash';
|
import { clone } from 'lodash';
|
||||||
import memoizeOne from 'memoize-one';
|
import memoize from 'micro-memoize';
|
||||||
import { Row } from 'react-table';
|
import { Row } from 'react-table';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -137,7 +137,7 @@ export function getColumns(
|
|||||||
sortType: selectSortType(field.type),
|
sortType: selectSortType(field.type),
|
||||||
width: fieldTableOptions.width,
|
width: fieldTableOptions.width,
|
||||||
minWidth: fieldTableOptions.minWidth ?? columnMinWidth,
|
minWidth: fieldTableOptions.minWidth ?? columnMinWidth,
|
||||||
filter: memoizeOne(filterByValue(field)),
|
filter: memoize(filterByValue(field)),
|
||||||
justifyContent: getTextAlign(field),
|
justifyContent: getTextAlign(field),
|
||||||
Footer: getFooterValue(fieldIndex, footerValues, isCountRowsSet),
|
Footer: getFooterValue(fieldIndex, footerValues, isCountRowsSet),
|
||||||
});
|
});
|
||||||
|
@ -106,14 +106,17 @@ export function useStyles<T>(getStyles: (theme: GrafanaTheme) => T) {
|
|||||||
* Prefer using primitive values (boolean, number, string, etc) for
|
* Prefer using primitive values (boolean, number, string, etc) for
|
||||||
* additional arguments for better performance
|
* additional arguments for better performance
|
||||||
*
|
*
|
||||||
|
* ```
|
||||||
* const getStyles = (theme, isDisabled, isOdd) => {css(...)}
|
* const getStyles = (theme, isDisabled, isOdd) => {css(...)}
|
||||||
* [...]
|
* [...]
|
||||||
* const styles = useStyles2(getStyles, true, Boolean(index % 2))
|
* const styles = useStyles2(getStyles, true, Boolean(index % 2))
|
||||||
|
* ```
|
||||||
*
|
*
|
||||||
* NOTE: For memoization to work, ensure that all arguments don't change
|
* NOTE: For memoization to work, ensure that all arguments don't change
|
||||||
* across renders (or only change if they need to)
|
* across renders (or only change if they need to)
|
||||||
|
*
|
||||||
|
* @public
|
||||||
* */
|
* */
|
||||||
/** @public */
|
|
||||||
export function useStyles2<T extends unknown[], CSSReturnValue>(
|
export function useStyles2<T extends unknown[], CSSReturnValue>(
|
||||||
getStyles: (theme: GrafanaTheme2, ...args: T) => CSSReturnValue,
|
getStyles: (theme: GrafanaTheme2, ...args: T) => CSSReturnValue,
|
||||||
...additionalArguments: T
|
...additionalArguments: T
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import memoizeOne from 'memoize-one';
|
import memoize from 'micro-memoize';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @public
|
* @public
|
||||||
@ -9,5 +9,5 @@ import memoizeOne from 'memoize-one';
|
|||||||
export function stylesFactory<ResultFn extends (this: any, ...newArgs: any[]) => ReturnType<ResultFn>>(
|
export function stylesFactory<ResultFn extends (this: any, ...newArgs: any[]) => ReturnType<ResultFn>>(
|
||||||
stylesCreator: ResultFn
|
stylesCreator: ResultFn
|
||||||
) {
|
) {
|
||||||
return memoizeOne(stylesCreator);
|
return memoize(stylesCreator);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user