feat(Gridler): ✨ add isValuesInPages method and update state handling
* Introduce isValuesInPages method to check if values exist in paginated data. * Update state management in GlidlerAPIAdaptorForGoLangv2 to clear values when no pages are found.
This commit is contained in:
@@ -272,9 +272,13 @@ function _GlidlerAPIAdaptorForGoLangv2<T = unknown>(props: GlidlerAPIAdaptorForG
|
||||
useEffect(() => {
|
||||
setState('useAPIQuery', useAPIQuery);
|
||||
setState('askAPIRowNumber', askAPIRowNumber);
|
||||
|
||||
const isValuesInPages = getState('isValuesInPages');
|
||||
|
||||
const _refresh = getState('_refresh');
|
||||
|
||||
if (!isValuesInPages) {
|
||||
setState('values', []);
|
||||
}
|
||||
|
||||
//Reset the loaded pages to new rules
|
||||
_refresh?.().then(() => {
|
||||
const onChange = getState('onChange');
|
||||
@@ -289,6 +293,8 @@ function _GlidlerAPIAdaptorForGoLangv2<T = unknown>(props: GlidlerAPIAdaptorForG
|
||||
return <></>;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//The computer component does not need to be recalculated on every render, so we use React.memo to prevent unnecessary re-renders.
|
||||
export const GlidlerAPIAdaptorForGoLangv2 = React.memo(_GlidlerAPIAdaptorForGoLangv2);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user