React/Browser - 是否有任何数据通过 useState 挂钩存储在用户设备上,post 页面刷新?

React/Browser - Does any data get stored on a user's device with a useState hook, post a page refresh?

给定一个用例,其中用户需要将数据输入 React 应用程序以进行即时计算。然而,从安全的角度来看,用户输入的数据不应该保存在用户的设备上,或者 React 应用程序中(假设我们没有明确地从 React/backend 逻辑角度将数据保存在任何地方)。

刷新页面后,useState 挂钩中包含的数据会发生什么变化? React 或浏览器 store/cache 是否有任何此类信息,或者是否已将其完全删除?

它刚刚恢复到初始状态。没有其他事情发生

const [post,setPost] = useState(false)

当页面刷新时它返回 false

React 状态完全存在于内存中。我只能存在于长期存储中,例如 localStorage,如果它被积极地保存在那里。

如果您重新加载浏览器 window,它会有效地重新加载 React 应用程序。之前 运行 的任何东西都被扔掉并重新开始。应用程序加载并且任何 React 组件都将具有其初始状态值。

What happens to that data contained within useState hooks after the page is refreshed? Does React or the Browser store/cache any of that information at all, or is it deleted entirely?

由于上述原因,它在页面重新加载时被擦除。