Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return function withStylesHOC(WrappedComponent) {
const wrappedComponentName = getComponentName(WrappedComponent);
// The wrapper component that injects the withStyles props
class WithStyles extends BaseClass {
constructor(props, context) {
super(props, context);
/** Cache for storing the current props and objects used to derive them */
this.cache = { rtl: {}, ltr: {} };
}
getCache(direction) {
return this.cache[direction];
}
updateCache(direction, results) {
this.cache[direction] = results;
}
}
render() {
const { direction } = this.state;
return (
);
}
}
const wrappedComponentName = getComponentName(WrappedComponent) || 'Component';
WithDirection.WrappedComponent = WrappedComponent;
WithDirection.contextTypes = contextTypes;
WithDirection.displayName = `withDirection(${wrappedComponentName})`;
if (WrappedComponent.propTypes) {
WithDirection.propTypes = deepmerge({}, WrappedComponent.propTypes);
delete WithDirection.propTypes.direction;
}
if (WrappedComponent.defaultProps) {
WithDirection.defaultProps = deepmerge({}, WrappedComponent.defaultProps);
}
return hoistNonReactStatics(WithDirection, WrappedComponent);
}
return function hoc(ComponentToWrap, ...hocParams) {
const NewComponent = componentAndParamsToComponent(
ComponentToWrap,
...(factory ? factoryParams : hocParams),
);
NewComponent.WrappedComponent = ComponentToWrap;
NewComponent.displayName = `${hocName}(${getComponentName(ComponentToWrap)})`;
if (ComponentToWrap.propTypes) {
const copiedProps = {
...sloppy(ComponentToWrap.propTypes),
};
passedProps.forEach((propName) => {
delete copiedProps[propName];
});
const newPropTypes = {
...copiedProps,
...(NewComponent.propTypes && sloppy(NewComponent.propTypes)),
};
if (allowExtraProps) {