You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

30 lines
544 B

import { useEffect, useRef } from 'react';
function NoopTransition({
children,
in: inProp,
mountOnEnter,
unmountOnExit
}) {
const hasEnteredRef = useRef(inProp);
useEffect(() => {
if (inProp) hasEnteredRef.current = true;
}, [inProp]);
if (inProp) return children; // not in
//
// if (!mountOnEnter && !unmountOnExit) {
// return children;
// }
if (unmountOnExit) {
return null;
}
if (!hasEnteredRef.current && mountOnEnter) {
return null;
}
return children;
}
export default NoopTransition;