feat(app): 优化Expo Updates更新检查机制,防止重复执行

This commit is contained in:
richarjiang
2025-12-06 10:05:19 +08:00
parent 0013dc3266
commit eef0134ddc

View File

@@ -485,7 +485,17 @@ function Bootstrapper({ children }: { children: React.ReactNode }) {
getPrivacyAgreed();
}, []);
// 使用 ref 确保更新检查只执行一次
const updateCheckRequestedRef = React.useRef(false);
useEffect(() => {
// 如果已经执行过更新检查,直接返回
if (updateCheckRequestedRef.current) {
return;
}
updateCheckRequestedRef.current = true;
async function checkUpdate() {
try {
logger.info(`Checking for updates..., env: ${__DEV__}, Updates.isEnabled: ${Updates.isEnabled}`);