mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-25 10:22:55 +08:00
fix(core): add null checks for timeout refs and event listeners for React 19 compatibility (#9116)
## Description - Add null checks before clearTimeout calls in colorful-fallback.tsx, edgeless.dialog.tsx, and local.dialog.tsx - Fix event listener cleanup in unfolding.tsx - Update tsconfig.jsx to use react-jsx transform ## Testing - [x] Verified type safety improvements for React 19 compatibility - [x] Ensured proper cleanup of event listeners and timeouts - [x] Confirmed no unintended side effects from the changes Link to Devin run: https://app.devin.ai/sessions/2e790f3ea0d84402837ec6c3c6f83e4c
This commit is contained in:
@@ -45,11 +45,11 @@ export function useEnsureLiveData<T>(liveData$: LiveData<T>): NonNullable<T> {
|
||||
|
||||
if (data === null || data === undefined) {
|
||||
return use(
|
||||
new Promise((resolve, reject) => {
|
||||
new Promise<NonNullable<T>>((resolve, reject) => {
|
||||
const subscription = liveData$.subscribe({
|
||||
next(value) {
|
||||
if (value === null || value === undefined) {
|
||||
resolve(value);
|
||||
if (value !== null && value !== undefined) {
|
||||
resolve(value as NonNullable<T>);
|
||||
subscription.unsubscribe();
|
||||
}
|
||||
},
|
||||
@@ -64,5 +64,5 @@ export function useEnsureLiveData<T>(liveData$: LiveData<T>): NonNullable<T> {
|
||||
);
|
||||
}
|
||||
|
||||
return data;
|
||||
return data as NonNullable<T>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user