mirror of
https://github.com/penxio/penx.git
synced 2026-04-19 03:03:06 -04:00
26 lines
440 B
TypeScript
26 lines
440 B
TypeScript
import { mutate, useStore } from 'stook'
|
|
|
|
const key = 'TEXT_SELECTED'
|
|
|
|
type State = {
|
|
text: string
|
|
selected?: boolean
|
|
}
|
|
|
|
export function useText() {
|
|
const [state, setState] = useStore<State>(key, { text: '' } as State)
|
|
const setText = (value: string) => {
|
|
setState((state) => {
|
|
state.text = value
|
|
})
|
|
}
|
|
return {
|
|
...state,
|
|
setText,
|
|
}
|
|
}
|
|
|
|
export function updateText(text: string) {
|
|
mutate(key, { text })
|
|
}
|