use-sync-state
v1.1.2
Published
use-sync-state
Downloads
3
Maintainers
Readme
使用
同步 state 模式
import useSyncState from 'use-sync-state'
export default () => {
const [status, setStatus] = useSyncState(1)
status.current // 1
setStatus(2)
status.current // 2
}
异步 state 模式
import React from 'react'
const { useState } = React
export default () => {
const [status, setStatus] = useState(1)
status // 1
setStatus(2)
status // 1
}