paradiego
This commit is contained in:
30
node_modules/@mui/material/node/utils/memoTheme.js
generated
vendored
Normal file
30
node_modules/@mui/material/node/utils/memoTheme.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = memoTheme;
|
||||
// We need to pass an argument as `{ theme }` for PigmentCSS, but we don't want to
|
||||
// allocate more objects.
|
||||
const arg = {
|
||||
theme: undefined
|
||||
};
|
||||
|
||||
/**
|
||||
* Memoize style function on theme.
|
||||
* Intended to be used in styled() calls that only need access to the theme.
|
||||
*/
|
||||
function memoTheme(styleFn) {
|
||||
let lastValue;
|
||||
let lastTheme;
|
||||
return props => {
|
||||
let value = lastValue;
|
||||
if (value === undefined || props.theme !== lastTheme) {
|
||||
arg.theme = props.theme;
|
||||
value = styleFn(arg);
|
||||
lastValue = value;
|
||||
lastTheme = props.theme;
|
||||
}
|
||||
return value;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user