Skip to content

Documentation is unclear when recommending outer track div #208

Description

@FabioGNR

The documentation mentions:

The track can be a single narrow div as in the Super simple example; however, it might be better to use at least two nested divs where the outer div is much thicker and has a transparent background and the inner div is narrow, has visible background and is centered. props should be then spread over the outer bigger div.

However, in fact if you do this there will be an issue because the trackRef will be set to the outer div, which results in no thumbs being found (it only checks direct children).
The Basic example also does it differently: https://github.com/tajo/react-range/blob/main/examples/Basic.tsx#L37

What I did for now is spread props over outer div, but set ref there to null explicitly. Then set ref={props.ref} for the inner div.

I think either the documentation should be updated to specify this, or perhaps the lib can look for thumbs in descendants instead of only direct children. Not sure if that will have side effects.

Thanks for this nice component!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions