Created
October 1, 2019 18:14
-
-
Save dc-nikolaev/051fd04f77098bc6a99f103fd5e6c38a to your computer and use it in GitHub Desktop.
ReactWindowScrollBars
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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