fix(Gridler): update ready state management logic
This commit is contained in:
@@ -7,7 +7,7 @@ import {
|
|||||||
} from '@glideapps/glide-data-grid';
|
} from '@glideapps/glide-data-grid';
|
||||||
import { Group, Stack } from '@mantine/core';
|
import { Group, Stack } from '@mantine/core';
|
||||||
import { useElementSize, useMergedRef } from '@mantine/hooks';
|
import { useElementSize, useMergedRef } from '@mantine/hooks';
|
||||||
import React from 'react';
|
import React, { useEffect } from 'react';
|
||||||
|
|
||||||
import { BottomBar } from './components/BottomBar';
|
import { BottomBar } from './components/BottomBar';
|
||||||
import { Computer } from './components/Computer';
|
import { Computer } from './components/Computer';
|
||||||
@@ -107,14 +107,22 @@ export const GridlerDataGrid = () => {
|
|||||||
setStateFN('_glideref', () => {
|
setStateFN('_glideref', () => {
|
||||||
return r ?? undefined;
|
return r ?? undefined;
|
||||||
});
|
});
|
||||||
|
|
||||||
const ready = getState('ready');
|
|
||||||
const newReady = !!(r && mounted);
|
|
||||||
if (ready !== newReady) {
|
|
||||||
setState('ready', newReady);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (ref.current && mounted) {
|
||||||
|
const currentReady = getState('ready');
|
||||||
|
if (!currentReady) {
|
||||||
|
setState('ready', true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const currentReady = getState('ready');
|
||||||
|
if (currentReady) {
|
||||||
|
setState('ready', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [mounted, getState, setState]);
|
||||||
|
|
||||||
const theme = useGridTheme();
|
const theme = useGridTheme();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user