Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use createSliderWithTooltip #856

Open
jcubic opened this issue Dec 8, 2022 · 5 comments
Open

How to use createSliderWithTooltip #856

jcubic opened this issue Dec 8, 2022 · 5 comments

Comments

@jcubic
Copy link

jcubic commented Dec 8, 2022

The code from the documentation doesn't work. It gives a warning from TypeScript that you can replace require with import but it throws a runtime error:

react-dom.development.js:11865 Uncaught TypeError: createSliderWithTooltip is not a function
@vf-telwing
Copy link

@jcubic It looks like this library was refactored recently and the most recent documentation now exists in the docs/ directory. Here is the implementation included for the TooltipSlider: https://github.com/react-component/slider/blob/master/docs/examples/components/TooltipSlider.tsx

@jcubic
Copy link
Author

jcubic commented Jan 6, 2023

I don't think I will waste more time on this.

@anik95
Copy link

anik95 commented Jan 10, 2023

Can you please let me know how this can be resolved?

This is what I have:
const { createSliderWithTooltip } = Slider;
const Range = createSliderWithTooltip(Slider.Range);

But this gives the following error:
Property 'createSliderWithTooltip' does not exist on type 'ForwardRefExoticComponent<SliderProps<number | number[]> & RefAttributes>'

@vf-telwing
Copy link

@anik95 Since createSliderWithTooltip no longer exists, the best reference point I was able to find is the TooltipSlider example: https://github.com/react-component/slider/blob/master/docs/examples/components/TooltipSlider.tsx

I think that component is the intended replacement for the code you are currently using.

@wzy1935
Copy link

wzy1935 commented Feb 12, 2023

I literally spent half of a day on this...

For anyone who encounter the same problem, my suggestions are:

  • Use old version of rc-slider, i.e., v9.x.x;
  • Use antd library instead, though it is huge;
  • Use the template mentioned above;
  • Giving up on the tooltip function, rc-tooltip is even more unreliable;

But if you insist on using this version of rc-slider by yourself, This is a cleaner example than the template above:

import React from "react";
import Slider from "rc-slider"; // 10.0.0
import Tooltip from "rc-tooltip"; // 5.1.1
import "rc-tooltip/assets/bootstrap_white.css";

export default () => (
  <div>
    <Slider
      handleRender={(node, handleProps) => {
        return (
          <Tooltip
            overlayInnerStyle={{ minHeight: "auto" }}
            overlay={"score: " + handleProps.value}
            placement="bottom"
          >
            {node}
          </Tooltip>
        );
      }}
      range
      min={0}
      max={10}
      defaultValue={[1, 2, 3]}
    ></Slider>
  </div>
);

Oh, never to mention that it generates error of ReactDOM.render is no longer supported in React 18 all the time.

Working on this is just WASTE OF TIME.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants