slider icon indicating copy to clipboard operation
slider copied to clipboard

Custom handle doesn't work

Open mvasin opened this issue 7 years ago • 2 comments
trafficstars

Custom handle doesn't seem to work.

Here's the code, also available on codesandbox:

import React from "react";
import ReactDOM from "react-dom";

import Slider from "rc-slider/lib/Slider";
import "rc-slider/assets/index.css";

const Handle = () => <span style={{fontSize: '3rem'}}>*</span>;

function App() {
  return (
    <div style={{ paddingTop: "30vh" }}>
      <Slider handle={Handle} />
    </div>
  );
}

const rootElement = document.getElementById("root");
ReactDOM.render(<App />, rootElement);

Here's the experience so far: handle

mvasin avatar Jul 18 '18 19:07 mvasin

The handle prop is quite low-level. It expects you to implement the Handle functionality yourself on your custom Handle.

But, you can use the existing Handle component and pass your custom children to it:

import Slider, { Handle } from 'rc-slider'

<Slider
    handle={ (handleProps) => {
        return (
            <Handle { ...handleProps }>
                <MyAwesomeComponent />
            </Handle>
        )
    }}
 />

draperunner avatar Jan 10 '19 14:01 draperunner

The code suggested by @draperunner works well. This issue can be closed now.

cseas avatar Jan 06 '21 07:01 cseas