From 1f7206a66fdf98b40067e9dd5ae10b76b5489732 Mon Sep 17 00:00:00 2001 From: vezwork Date: Mon, 16 May 2022 10:48:54 -0400 Subject: [PATCH] Replace few usages of useRefAndState with useState --- .../RightOverlay/HorizontalScrollbar.tsx | 23 +++++++++---------- .../uiComponents/form/BasicNumberInput.tsx | 7 +++--- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/theatre/studio/src/panels/SequenceEditorPanel/RightOverlay/HorizontalScrollbar.tsx b/theatre/studio/src/panels/SequenceEditorPanel/RightOverlay/HorizontalScrollbar.tsx index 6e2981f..828f662 100644 --- a/theatre/studio/src/panels/SequenceEditorPanel/RightOverlay/HorizontalScrollbar.tsx +++ b/theatre/studio/src/panels/SequenceEditorPanel/RightOverlay/HorizontalScrollbar.tsx @@ -10,7 +10,6 @@ import styled from 'styled-components' import {zIndexes} from '@theatre/studio/panels/SequenceEditorPanel/SequenceEditorPanel' import {includeLockFrameStampAttrs} from '@theatre/studio/panels/SequenceEditorPanel/FrameStampPositionProvider' import {pointerEventsAutoInNormalMode} from '@theatre/studio/css' -import useRefAndState from '@theatre/studio/utils/useRefAndState' import useDrag from '@theatre/studio/uiComponents/useDrag' const Container = styled.div` @@ -258,26 +257,26 @@ const HorizontalScrollbar: React.FC<{ return self }, [layoutP, relevantValuesD]) - const [refRangeDrag, nodeRangeDrag] = useRefAndState( + const [rangeDragNode, setRangeDragNode] = useState( null, ) - useDrag(nodeRangeDrag, { + useDrag(rangeDragNode, { debugName: 'HorizontalScrollbar/onRangeDrag', onDragStart: handles.onRangeDragStart, lockCSSCursorTo: 'ew-resize', }) - const [refRangeStartDrag, nodeRangeStartDrag] = - useRefAndState(null) - useDrag(nodeRangeStartDrag, { + const [rangeStartDragNode, setRangeStartDragNode] = + useState(null) + useDrag(rangeStartDragNode, { debugName: 'HorizontalScrollbar/onRangeStartDrag', onDragStart: handles.onRangeStartDragStart, lockCSSCursorTo: 'w-resize', }) - const [refRangeEndDrag, nodeRangeEndDrag] = - useRefAndState(null) - useDrag(nodeRangeEndDrag, { + const [rangeEndDragNode, setRangeEndDragNode] = + useState(null) + useDrag(rangeEndDragNode, { debugName: 'HorizontalScrollbar/onRangeEndDrag', onDragStart: handles.onRangeEndDragStart, lockCSSCursorTo: 'e-resize', @@ -290,14 +289,14 @@ const HorizontalScrollbar: React.FC<{ > @@ -305,7 +304,7 @@ const HorizontalScrollbar: React.FC<{ diff --git a/theatre/studio/src/uiComponents/form/BasicNumberInput.tsx b/theatre/studio/src/uiComponents/form/BasicNumberInput.tsx index a9eb32d..1ae4e10 100644 --- a/theatre/studio/src/uiComponents/form/BasicNumberInput.tsx +++ b/theatre/studio/src/uiComponents/form/BasicNumberInput.tsx @@ -1,5 +1,6 @@ import {clamp, isInteger, round} from 'lodash-es' import type {MutableRefObject} from 'react' +import {useState} from 'react' import React, {useMemo, useRef} from 'react' import styled from 'styled-components' import mergeRefs from 'react-merge-refs' @@ -320,8 +321,8 @@ const BasicNumberInput: React.FC<{ /> ) : null - const [refDrag, nodeDrag] = useRefAndState(null) - useDrag(nodeDrag, { + const [dragNode, setDragNode] = useState(null) + useDrag(dragNode, { debugName: 'form/BasicNumberInput', onDragStart: callbacks.transitionToDraggingMode, lockCSSCursorTo: 'ew-resize', @@ -331,7 +332,7 @@ const BasicNumberInput: React.FC<{ return ( - {theInput} + {theInput} {fillIndicator} )