useHook
自定义hooks 返回jsx时, 这个自定义的hooks吗和函数式组件没什么区别
自定义组件里获取文件数据, 如果hook组件里点了删除, 如何让自定义组件里的数据重新获取更新
function Example () {
const [count, setCount] = useState(0);
const update = useUpdate()
console.log(update, '是否更新')
return (
<div>
<div>{count}</div>
<button onClick={() => {setCount(count+1)}}>+</button>
</div>
)
}
function useUpdate () {
const ref = useRef(false)
useEffect(() => {
ref.current = true
})
return ref.current
}最后更新于