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 does value work in knob? #20

Open
julian-kunzig opened this issue Jun 5, 2020 · 5 comments
Open

How does value work in knob? #20

julian-kunzig opened this issue Jun 5, 2020 · 5 comments

Comments

@julian-kunzig
Copy link

When update the value In the knob, it doesn't bind to knob.
The value of knob seem to work like initial value in the component.
I input state to value of knob and it worked in initial loading but when update the state of component, it wasn't updated.

@julian-kunzig
Copy link
Author

julian-kunzig commented Jun 5, 2020

I checked the knob library and confirmed value works like initial value.

Screenshot at Jun 05 06-48-25

@julian-kunzig
Copy link
Author

As temp solution I tried to redraw the knob component when value value was updated.
codesandbox
The value of knob is updated but the problem is Arc stopped to work correctly.
Any idea?

@lukedar
Copy link

lukedar commented Jun 27, 2021

@julian-kunzig did you find a way to make this a controlled component by updating it via value prop?

@vallsv
Copy link

vallsv commented Jul 15, 2021

Hi @lukedar, i did found this trick: you can inject a position to each sub components

    <Knob
        ...
    >
      <Pointer
        percentage={value / 360}
        ...
      <Value
        value={value}
      />

Could be better, but this way i was able to create nice result. Maybe even more complex than a single value stored in the knob prop.

@vallsv
Copy link

vallsv commented Jul 15, 2021

You must not use 360, but (value - min) / (max - min), which could be a bit annoying in your case.

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

3 participants