|
@@ -1,4 +1,4 @@
|
|
|
-import { useEffect, useRef } from 'react';
|
|
|
|
|
|
|
+import { useEffect, useRef, useState } from 'react';
|
|
|
|
|
|
|
|
import {
|
|
import {
|
|
|
usePageTreeInformationGeneration,
|
|
usePageTreeInformationGeneration,
|
|
@@ -21,18 +21,18 @@ type UseTreeRevalidationOptions = {
|
|
|
export const useTreeRevalidation = (options: UseTreeRevalidationOptions) => {
|
|
export const useTreeRevalidation = (options: UseTreeRevalidationOptions) => {
|
|
|
const { tree, triggerTreeRebuild } = options;
|
|
const { tree, triggerTreeRebuild } = options;
|
|
|
|
|
|
|
|
- // Track local generation number
|
|
|
|
|
- const localGenerationRef = useRef(1);
|
|
|
|
|
|
|
+ // Track local generation number with state to trigger re-renders
|
|
|
|
|
+ const [localGeneration, setLocalGeneration] = useState(1);
|
|
|
const globalGeneration = usePageTreeInformationGeneration();
|
|
const globalGeneration = usePageTreeInformationGeneration();
|
|
|
|
|
|
|
|
// Refetch data when global generation is updated
|
|
// Refetch data when global generation is updated
|
|
|
usePageTreeRevalidationEffect(
|
|
usePageTreeRevalidationEffect(
|
|
|
tree as Parameters<typeof usePageTreeRevalidationEffect>[0],
|
|
tree as Parameters<typeof usePageTreeRevalidationEffect>[0],
|
|
|
- localGenerationRef.current,
|
|
|
|
|
|
|
+ localGeneration,
|
|
|
{
|
|
{
|
|
|
// Update local generation number after revalidation
|
|
// Update local generation number after revalidation
|
|
|
onRevalidated: () => {
|
|
onRevalidated: () => {
|
|
|
- localGenerationRef.current = globalGeneration;
|
|
|
|
|
|
|
+ setLocalGeneration(globalGeneration);
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
);
|
|
);
|