Create edit dashboard action (#14564)
Closes https://github.com/twentyhq/core-team-issues/issues/1435 Introduced a new pattern to force to register an action or not. Discussed this with @charlesBochet
This commit is contained in:
+4
-1
@@ -14,10 +14,12 @@ import { isDeeplyEqual } from '~/utils/isDeeplyEqual';
|
||||
|
||||
type PageLayoutInitializationQueryEffectProps = {
|
||||
pageLayoutId: string;
|
||||
onInitialized: (pageLayout: PageLayoutWithData) => void;
|
||||
};
|
||||
|
||||
export const PageLayoutInitializationQueryEffect = ({
|
||||
pageLayoutId,
|
||||
onInitialized,
|
||||
}: PageLayoutInitializationQueryEffectProps) => {
|
||||
const [isInitialized, setIsInitialized] = useState(false);
|
||||
|
||||
@@ -88,9 +90,10 @@ export const PageLayoutInitializationQueryEffect = ({
|
||||
useEffect(() => {
|
||||
if (!isInitialized && isDefined(pageLayout)) {
|
||||
initializePageLayout(pageLayout);
|
||||
onInitialized?.(pageLayout);
|
||||
setIsInitialized(true);
|
||||
}
|
||||
}, [initializePageLayout, isInitialized, pageLayout]);
|
||||
}, [initializePageLayout, isInitialized, pageLayout, onInitialized]);
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user