mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
26 lines
614 B
React
26 lines
614 B
React
import React, { useEffect } from "react";
|
|||
|
|
import { Link } from "react-router-dom";
|
||
|
|
|
||
|
|
const ForwardRefLink = React.forwardRef((props, ref) => {
|
||
|
|
const { children, setRefAndCid, onMouseOver, onMouseLeave, onClick, ...otherProps } = props;
|
||
|
|
|
||
|
|
useEffect(() => {
|
||
|
|
if (ref.current && typeof setRefAndCid === 'function') {
|
||
|
|
setRefAndCid(ref.current);
|
||
|
|
}
|
||
|
|
}, [ref, setRefAndCid]);
|
||
|
|
|
||
|
|
return (
|
||
|
|
<Link
|
||
|
|
ref={ref}
|
||
|
|
{...otherProps}
|
||
|
|
onMouseOver={onMouseOver}
|
||
|
|
onMouseLeave={onMouseLeave}
|
||
|
|
onClick={onClick}
|
||
|
|
>
|
||
|
|
{children}
|
||
|
|
</Link>
|
||
|
|
);
|
||
|
|
});
|
||
|
|
|
||
|
|
export default ForwardRefLink;
|