Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F121757045
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
Sun, Jul 13, 16:17
Size
1 KB
Mime Type
text/x-java
Expires
Tue, Jul 15, 16:17 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
27385690
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