Giter Site home page Giter Site logo

Comments (6)

tajo avatar tajo commented on May 18, 2024

Hey, can you provide the full example?

from react-range.

mariothedev avatar mariothedev commented on May 18, 2024

`
import { Range } from 'react-range';

<Range
step={0.1}
min={0}
max={100}
values={[10, 14]}
renderTrack={({ children }) => (
<div
style={{
height: '6px',
width: '100%',
backgroundColor: '#ccc'
}}
>
{children}

)}
renderThumb={() => (
<div
style={{
height: '42px',
width: '42px',
backgroundColor: '#999'
}}
/>
)}
/>`

from react-range.

tajo avatar tajo commented on May 18, 2024

You need to spread over some props over your divs. They are being passed through in renderTrack / renderThumb. Check the examples.

from react-range.

elderapo avatar elderapo commented on May 18, 2024

I am experiencing the same error:

Uncaught TypeError: Cannot read property 'getBoundingClientRect' of null
    at Range._this.getOffsets (Range.js:42)
    at Range._this.onResize (Range.js:134)
    at utils.js:131

happens when native prop gets changed.

from react-range.

tajo avatar tajo commented on May 18, 2024

happens when native prop gets changed.

What is native prop? Can you please provide a full example?

from react-range.

elderapo avatar elderapo commented on May 18, 2024

Actually this is a little bit awkward... I confused 2 libraries: react-range and react-custom-scrollbars. 🤭

Nonetheless react-custom-scrollbars seems to break react-range under some circumstances... Unfortunately, I didn't manage to create a small reproducible repo but I figured out this happens when changing native prop in react-custom-scrollbars which I guess ends up unmounting all the children and them mounts them again. This seems to cause react-range to lose ref (trackRef) and throw this error on first render (?) after unmount/mount.

_this.getOffsets = function () {
            var _a = _this.props, direction = _a.direction, values = _a.values, min = _a.min, max = _a.max;
            var trackElement = _this.trackRef.current;
            var trackRect = trackElement.getBoundingClientRect(); <-------------------
            var trackPadding = utils_1.getPaddingAndBorder(trackElement);

I am not familiar at all with react-range but does my theory make sense? If you want I could privately send you a link to my app with source maps enabled so you could debug it further.

@edit:

Just checked and it's a call to getOffsets from onResize that's causing this.

from react-range.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.