use react version on website

This commit is contained in:
Rene Haas
2022-11-16 16:01:41 +01:00
parent 400afe695e
commit b77012d714
12 changed files with 58 additions and 148 deletions
+9 -22
View File
@@ -1,26 +1,13 @@
import { useEffect, useRef } from 'react';
import { useOverlayScrollbarsIdle } from '~/hooks/useOverlayScrollbarsIdle';
import { OverlayScrollbarsComponent } from 'overlayscrollbars-react';
import type { ComponentProps } from 'react';
export const Pre = ({ children }: ComponentProps<'pre'>) => {
const ref = useRef(null);
const [initialize, instance] = useOverlayScrollbarsIdle({
options: {
export const Pre = ({ children }: ComponentProps<'pre'>) => (
<OverlayScrollbarsComponent
element="pre"
options={{
paddingAbsolute: true,
scrollbars: { autoHide: 'leave' },
},
});
useEffect(() => {
if (ref.current) {
initialize(ref.current);
return () => instance()?.destroy();
}
}, []);
return (
<pre ref={ref} data-overlayscrollbars-initialize>
{children}
</pre>
);
};
}}>
{children}
</OverlayScrollbarsComponent>
);