@mackin.com/styleguide 9.3.2 → 9.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +10 -1
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -3697,10 +3697,19 @@ const GlobalStyles = (p) => {
|
|
|
3697
3697
|
const Slider = (p) => {
|
|
3698
3698
|
var _a;
|
|
3699
3699
|
const theme = useThemeSafely();
|
|
3700
|
-
const currentValue = React.useRef(p.value);
|
|
3701
3700
|
const sliderContainer = React.useRef(null);
|
|
3702
3701
|
const sliderHandleSize = (_a = p.sliderHandleSize) !== null && _a !== void 0 ? _a : theme.controls.height;
|
|
3703
3702
|
const height = p.showValue ? `calc(${sliderHandleSize} + 1.5rem)` : sliderHandleSize;
|
|
3703
|
+
// we're keeping this value in a ref vs. state so the constant updates don't cause re-render.
|
|
3704
|
+
// we will have to respond to outside value changes after the fact however...
|
|
3705
|
+
const currentValue = React.useRef(p.value);
|
|
3706
|
+
const [, forceUpdate] = React.useState(Date.now());
|
|
3707
|
+
React.useEffect(() => {
|
|
3708
|
+
if (p.value !== currentValue.current) {
|
|
3709
|
+
currentValue.current = p.value;
|
|
3710
|
+
forceUpdate(Date.now());
|
|
3711
|
+
}
|
|
3712
|
+
}, [p.value]);
|
|
3704
3713
|
return (React__default['default'].createElement("div", { ref: sliderContainer, className: css.cx(css.css({
|
|
3705
3714
|
label: 'Slider',
|
|
3706
3715
|
width: '100%',
|