Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F101464207
requirePropFactory.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
Mon, Feb 10, 17:30
Size
1 KB
Mime Type
text/x-java
Expires
Wed, Feb 12, 17:30 (2 d)
Engine
blob
Format
Raw Data
Handle
24170504
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
requirePropFactory.js
View Options
import _extends from "@babel/runtime/helpers/esm/extends";
export default function requirePropFactory(componentNameInError, Component) {
if (process.env.NODE_ENV === 'production') {
return () => null;
}
// eslint-disable-next-line react/forbid-foreign-prop-types
const prevPropTypes = Component ? _extends({}, Component.propTypes) : null;
const requireProp = requiredProp => (props, propName, componentName, location, propFullName, ...args) => {
const propFullNameSafe = propFullName || propName;
const defaultTypeChecker = prevPropTypes == null ? void 0 : prevPropTypes[propFullNameSafe];
if (defaultTypeChecker) {
const typeCheckerResult = defaultTypeChecker(props, propName, componentName, location, propFullName, ...args);
if (typeCheckerResult) {
return typeCheckerResult;
}
}
if (typeof props[propName] !== 'undefined' && !props[requiredProp]) {
return new Error(`The prop \`${propFullNameSafe}\` of ` + `\`${componentNameInError}\` can only be used together with the \`${requiredProp}\` prop.`);
}
return null;
};
return requireProp;
}
Event Timeline
Log In to Comment