refactor hooks
This commit is contained in:
parent
80d67c4518
commit
6e82468692
|
|
@ -4,10 +4,7 @@ import { Texture, TextureType } from '../types'
|
|||
|
||||
type Response = fetch.ResponseBody<Texture>
|
||||
|
||||
export default function useTexture(): [
|
||||
{ url: string; type: TextureType },
|
||||
React.Dispatch<React.SetStateAction<number>>,
|
||||
] {
|
||||
export default function useTexture() {
|
||||
const [tid, setTid] = useState(0)
|
||||
const [url, setUrl] = useState('')
|
||||
const [type, setType] = useState<TextureType>('steve')
|
||||
|
|
@ -29,5 +26,5 @@ export default function useTexture(): [
|
|||
getTexture()
|
||||
}, [tid])
|
||||
|
||||
return [{ url, type }, setTid]
|
||||
return [{ url, type }, setTid] as const
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
import React, { useState, useEffect, useRef } from 'react'
|
||||
import { useState, useEffect, useRef } from 'react'
|
||||
import TWEEN from '@tweenjs/tween.js'
|
||||
|
||||
export default function useTween<T = any>(
|
||||
initialValue: T,
|
||||
): [T, React.Dispatch<React.SetStateAction<T>>] {
|
||||
export default function useTween<T = any>(initialValue: T) {
|
||||
const [value, setValue] = useState<T>(initialValue)
|
||||
const ref = useRef<T>(value)
|
||||
const [dest, setDest] = useState<T>(initialValue)
|
||||
|
|
@ -20,5 +18,5 @@ export default function useTween<T = any>(
|
|||
animate()
|
||||
}, [dest])
|
||||
|
||||
return [value, setDest]
|
||||
return [value, setDest] as const
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user