Skip to content

React

在客户端入口、创建 Router 之前安装一次:

tsx
import { install } from "@revfanc/guard"

install()

组件只管理自己的 Handler:

tsx
import { useEffect } from "react"
import { create } from "@revfanc/guard"

useEffect(() => {
  return create(async (resolve) => {
    if (await confirmLeaving()) resolve()
  })
}, [])

React effect cleanup 会同步移除该层。嵌套组件自然按挂载顺序形成 LIFO 栈。

Released under the MIT License.