react-scrollbars-custom icon indicating copy to clipboard operation
react-scrollbars-custom copied to clipboard

Can't use <ol> element as contentElement

Open billerr opened this issue 5 years ago • 1 comments

What is the current behavior?

I'm trying to output an <ol> element as my content element, using contentProps as in the docs. However, the ref type shows an incompatibility error:

Type 'ElementRef<HTMLDivElement> | undefined' is not assignable to type 'string | ((instance: HTMLOListElement | null) => void) | RefObject<HTMLOListElement> | null | undefined'.

Maybe I'm doing something wrong, or I need to override the default ElementRef generic type,, but I couldn't get more info on howw to do this from the docs.

Steps to reproduce it : Here is the code (the error shows up on the "ref" prop):

<Scrollbar 
    noScrollX 
    removeTrackXWhenNotUsed 
    mobileNative 
    onUpdate={ scrollHandler } 
    contentProps={{
        renderer: ({ elementRef, ...props}) =>(
            <ol {...props} className="Form__stepList" ref={ elementRef } />
        )
    }}>
    <li ...></li>
    <li ...></li>
    <li ...></li>
</Scrollbar>

What is the expected behavior? I should be able to substitute the default <div> element for the contentElement with an <ol> element.

A little about versions:

  • OS: Windows 10
  • Browser (vendor and version): Electron (latest)
  • React: 16.9 (w Typescript)
  • react-scrollbars-custom: latest
  • Did this worked in the previous package version? don't know

billerr avatar Nov 18 '19 16:11 billerr

That is definely library error, cuz these types are not generic. I'll fix the typing as soon ill have some time (sadly i have no time now and wont have till NY)

xobotyi avatar Nov 18 '19 19:11 xobotyi