From acc7081036177e036bd7f43c7975939d33e91f2c Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Fri, 25 Jun 2021 17:05:14 -0400 Subject: Cleanup ref types --- src/components/common/MomentTags.tsx | 14 +++++--------- src/components/moments/MomentPost.tsx | 12 +++++++++++- src/components/taggs/TaggDraggable.tsx | 4 ++-- 3 files changed, 18 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/components/common/MomentTags.tsx b/src/components/common/MomentTags.tsx index 4afacddb..d8a70353 100644 --- a/src/components/common/MomentTags.tsx +++ b/src/components/common/MomentTags.tsx @@ -1,4 +1,5 @@ -import React, {createRef, MutableRefObject, useEffect, useState} from 'react'; +import React, {createRef, RefObject, useEffect, useState} from 'react'; +import {Image, View} from 'react-native'; import {MomentTagType, ProfilePreviewType} from '../../types'; import TaggDraggable from '../taggs/TaggDraggable'; import Draggable from './Draggable'; @@ -7,7 +8,7 @@ interface MomentTagsProps { editing: boolean; tags: MomentTagType[]; setTags: (tag: MomentTagType[]) => void; - imageRef: MutableRefObject; + imageRef: RefObject; deleteFromList?: (user: ProfilePreviewType) => void; } @@ -21,14 +22,9 @@ const MomentTags: React.FC = ({ const [offset, setOffset] = useState([0, 0]); const [imageDimensions, setImageDimensions] = useState([0, 0]); const [maxZIndex, setMaxZIndex] = useState(1); - const [draggableRefs, setDraggableRefs] = useState< - React.MutableRefObject[] - >([]); + const [draggableRefs, setDraggableRefs] = useState[]>([]); - const updateTagPosition = ( - ref: React.MutableRefObject, - userId: string, - ) => { + const updateTagPosition = (ref: RefObject, userId: string) => { if (ref !== null && ref.current !== null) { ref.current.measure( ( diff --git a/src/components/moments/MomentPost.tsx b/src/components/moments/MomentPost.tsx index e6bb5405..7d0752d5 100644 --- a/src/components/moments/MomentPost.tsx +++ b/src/components/moments/MomentPost.tsx @@ -1,5 +1,13 @@ import {useNavigation} from '@react-navigation/native'; -import React, {useContext, useEffect, useRef, useState} from 'react'; +import React, { + createRef, + LegacyRef, + MutableRefObject, + useContext, + useEffect, + useRef, + useState, +} from 'react'; import { Image, KeyboardAvoidingView, @@ -72,6 +80,7 @@ const MomentPost: React.FC = ({ const [momentTagId, setMomentTagId] = useState(''); const imageRef = useRef(null); + const videoRef = useRef