2
0

feat(editor): 🚸 Improve and unify inputs

This commit is contained in:
Baptiste Arnaud
2022-03-10 11:34:55 +01:00
parent 36838f05d3
commit 2c1f69439b
32 changed files with 187 additions and 251 deletions

View File

@ -1,2 +1,3 @@
export * from './utils'
export * from './useUndo'
export * from './useRefState'

View File

@ -0,0 +1,10 @@
import { useEffect, useRef, useState } from 'react'
export const useRefState = (initialValue: string) => {
const [state, setState] = useState(initialValue)
const stateRef = useRef<string>(state)
useEffect(() => {
stateRef.current = state
}, [state])
return [stateRef, setState]
}