Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F104933136
createStyleSheet.js
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Mar 13, 11:43
Size
1 KB
Mime Type
text/x-java
Expires
Sat, Mar 15, 11:43 (1 d, 21 h)
Engine
blob
Format
Raw Data
Handle
24882348
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
createStyleSheet.js
View Options
import merge from 'lodash/merge';
import memoize from 'lodash/memoize';
import jss from './setupjss';
import * as theme from './theme';
/**
* By default lodash/memoize only uses the first argument
* for cache rendering. It works well if the first prameter
* is enough.
* We are Hot Module Replacing (HMR) stylesheets.
* Therefore, we cannot cache stylesheet only by component.
* We need to add cssRevisions to the key fo when the css files update,
* the revision will update and we should update the stylesheet.
*/
export default memoize(function (styles, config, componentName, cssRevision) {
var mergedTheme = merge({}, theme, config.theme);
var customStyles = typeof config.styles === 'function' ? config.styles(mergedTheme) : config.styles;
var mergedStyles = merge({}, styles(mergedTheme), customStyles && customStyles[componentName]);
return jss.createStyleSheet(mergedStyles, {
meta: componentName,
link: true
});
}, // calculate the cache key here
function (styles, config, componentName, cssRevision) {
return componentName + "_" + cssRevision;
});
Event Timeline
Log In to Comment