fix: Added a fallback for module context (#13190)

Co-authored-by: Kavin Venkatachalam <kavin.saratha@gmail.com>
This commit is contained in:
Muhsin Shah C P 2025-07-04 12:03:18 +05:30 committed by GitHub
parent cf3fbfc2cb
commit f6ed13e550
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -13,7 +13,7 @@ export const ModuleProvider = ({ moduleId, isModuleMode, appType, isModuleEditor
export const useModuleContext = () => {
const context = useContext(ModuleContext);
if (!context) {
throw new Error('useModuleContext must be used within a ModuleProvider');
return { moduleId: 'canvas', isModuleMode: false, isModuleEditor: false };
}
return context;
};
@ -21,7 +21,7 @@ export const useModuleContext = () => {
export const useModuleId = () => {
const context = useContext(ModuleContext);
if (!context) {
throw new Error('useModuleId must be used within a ModuleProvider');
return 'canvas';
}
return context.moduleId;