Skip to content

Instantly share code, notes, and snippets.

@dc-nikolaev
Created October 1, 2019 18:14
Show Gist options
  • Save dc-nikolaev/051fd04f77098bc6a99f103fd5e6c38a to your computer and use it in GitHub Desktop.
Save dc-nikolaev/051fd04f77098bc6a99f103fd5e6c38a to your computer and use it in GitHub Desktop.
ReactWindowScrollBars
import React, { FunctionComponent, useCallback } from 'react';
import ScrollBars from '../../../../../components/ScrollBars';
const ReactWindowScrollBars: FunctionComponent<any> = ({ onScroll, forwardedRef, style, children }) => {
const refSetter = useCallback((scrollbarsRef) => {
if (scrollbarsRef) {
forwardedRef(scrollbarsRef.view);
} else {
forwardedRef(null);
}
}, []);
return (
<ScrollBars ref={refSetter} style={{ ...style, overflow: 'hidden' }} onScroll={onScroll}>
{children}
</ScrollBars>
);
};
export default React.forwardRef((props, ref) => <ReactWindowScrollBars {...props} forwardedRef={ref} />);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment