You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The slider currently takes props like position and moves them to internal states. This is moslty fine but leads to edge cases as shown in #64 in #48.
Option 1 - Standalone Hook
The state for the main component could be abstracted into it's own hook and exported from the library. The slider component itself would not call the hook, the parent component would instead. This would allow the parent component to manipulate all state and share it with ReactCompareSlider.
useimperativehandle may be a simpler option from a DX perspective as the API for v2 and v3 would remain the same but you could optionally call the hook to access the internal properties of the slider.
The text was updated successfully, but these errors were encountered:
nerdyman
changed the title
Make component completely controllable from the parent (resolves #64)
Make component completely controllable from the parent
Nov 15, 2022
The slider currently takes props like
position
and moves them to internal states. This is moslty fine but leads to edge cases as shown in #64 in #48.Option 1 - Standalone Hook
The state for the main component could be abstracted into it's own hook and exported from the library. The slider component itself would not call the hook, the parent component would instead. This would allow the parent component to manipulate all state and share it with
ReactCompareSlider
.E.g.
Option 2 -
useimperativehandle
useimperativehandle
may be a simpler option from a DX perspective as the API for v2 and v3 would remain the same but you could optionally call the hook to access the internal properties of the slider.The text was updated successfully, but these errors were encountered: