Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Passing an array of values

See original GitHub issue

Describe the Feature

A values props that takes an array of discrete values and only allows the slider to go through those values, e.g. see this jquery widget.

Possible Implementations

Not sure yet. Going to look into it and add it. Would you be interested in a pull request?

Related Issues


Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

nsdubcommented, Dec 14, 2020

Until this is formally supported, here’s a workaround that worked well for my use case:

Slider component…

  style={{width: '100%', height: 40}}
  onValueChange={(value) => {this.sliderValueChange(value)}}

And the sliderValueChange function…

sliderValueChange = (value) => {
  // Array of desired values
  const array = [5, 10, 15, 30, 45, 60]

  const output = array.reduce((prev, curr) => Math.abs(curr - value) < Math.abs(prev - value) ? curr : prev)

  // ... Pass output to UI, state, whatever
cltsangcommented, Nov 26, 2019

Very preliminary way to wrap Slider to enable this:

  const renderSlider = (optionsArray, initialValue, onSlidingComplete) => (
      maximumValue={optionsArray.length - 1}
      onSlidingComplete={(value) => onSlidingComplete(optionsArray[value])}
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to pass an array by value in C ? - GeeksforGeeks
This can be done by wrapping the array in a structure and creating a variable of type of that structure and assigning values...
Read more >
5.11.4. Passing Arrays to Functions
To pass an array as a parameter to a function, pass it as a pointer (since it is a pointer). For example, the...
Read more >
Pass arrays to a function in C - Programiz
In this tutorial, you'll learn to pass arrays (both one-dimensional and multidimensional arrays) to a function in C programming with the help of...
Read more >
Passing Arrays as Function Arguments in C - Tutorialspoint
If you want to pass a single-dimension array as an argument in a function, you would have to declare a formal parameter in...
Read more >
Pass an array by value to a function in C/C++ | Techie Delight
However, arrays in C cannot be passed by value to a function, and we can modify the contents of the array from within...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found