Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F124488333
TransitionWrapper.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
Sat, Aug 2, 19:50
Size
1 KB
Mime Type
text/x-java
Expires
Mon, Aug 4, 19:50 (2 d)
Engine
blob
Format
Raw Data
Handle
27831017
Attached To
rOACCT Open Access Compliance Check Tool (OACCT)
TransitionWrapper.js
View Options
import
React
,
{
useCallback
,
useRef
}
from
'react'
;
import
Transition
from
'react-transition-group/Transition'
;
import
useMergedRefs
from
'@restart/hooks/useMergedRefs'
;
import
safeFindDOMNode
from
'./safeFindDOMNode'
;
import
{
jsx
as
_jsx
}
from
"react/jsx-runtime"
;
// Normalizes Transition callbacks when nodeRef is used.
const
TransitionWrapper
=
/*#__PURE__*/
React
.
forwardRef
(({
onEnter
,
onEntering
,
onEntered
,
onExit
,
onExiting
,
onExited
,
addEndListener
,
children
,
childRef
,
...
props
},
ref
)
=>
{
const
nodeRef
=
useRef
(
null
);
const
mergedRef
=
useMergedRefs
(
nodeRef
,
childRef
);
const
attachRef
=
r
=>
{
mergedRef
(
safeFindDOMNode
(
r
));
};
const
normalize
=
callback
=>
param
=>
{
if
(
callback
&&
nodeRef
.
current
)
{
callback
(
nodeRef
.
current
,
param
);
}
};
/* eslint-disable react-hooks/exhaustive-deps */
const
handleEnter
=
useCallback
(
normalize
(
onEnter
),
[
onEnter
]);
const
handleEntering
=
useCallback
(
normalize
(
onEntering
),
[
onEntering
]);
const
handleEntered
=
useCallback
(
normalize
(
onEntered
),
[
onEntered
]);
const
handleExit
=
useCallback
(
normalize
(
onExit
),
[
onExit
]);
const
handleExiting
=
useCallback
(
normalize
(
onExiting
),
[
onExiting
]);
const
handleExited
=
useCallback
(
normalize
(
onExited
),
[
onExited
]);
const
handleAddEndListener
=
useCallback
(
normalize
(
addEndListener
),
[
addEndListener
]);
/* eslint-enable react-hooks/exhaustive-deps */
return
/*#__PURE__*/
_jsx
(
Transition
,
{
ref
:
ref
,
...
props
,
onEnter
:
handleEnter
,
onEntered
:
handleEntered
,
onEntering
:
handleEntering
,
onExit
:
handleExit
,
onExited
:
handleExited
,
onExiting
:
handleExiting
,
addEndListener
:
handleAddEndListener
,
nodeRef
:
nodeRef
,
children
:
typeof
children
===
'function'
?
(
status
,
innerProps
)
=>
children
(
status
,
{
...
innerProps
,
ref
:
attachRef
})
:
/*#__PURE__*/
React
.
cloneElement
(
children
,
{
ref
:
attachRef
})
});
});
export
default
TransitionWrapper
;
Event Timeline
Log In to Comment