Bug description
When i using the embedded SDK, got an error.
useTheme() could not find a ThemeContext. The <ThemeProvider/> component is likely missing from the app.
at useTheme (webpack-internal:///./packages/superset-ui-core/src/theme/index.tsx:61:11)
at Loading (webpack-internal:///./packages/superset-ui-core/src/components/Loading/index.tsx:64:65)
https://github.com/apache/superset/blob/dced2f8564ce65161312ee579dc47359958d4c15/superset-frontend/packages/superset-ui-core/src/components/Loading/index.tsx#L61-L71
https://github.com/apache/superset/blob/dced2f8564ce65161312ee579dc47359958d4c15/superset-frontend/src/embedded/index.tsx#L93-L102
Because the latest Loading used useTheme.
But in embedded applications, the Loading component is used as a fallback for Suspense, but it is located outside of EmbeddedContextProviders, resulting in the inability to access the theme context.
Screenshots/recordings
Superset version
master / latest-dev
Python version
3.9
Node version
16
Browser
Chrome
Additional context
No response
Checklist
- [ ] I have searched Superset docs and Slack and didn't find a solution to my problem.
- [ ] I have searched the GitHub issue tracker and didn't find a similar bug report.
- [ ] I have checked Superset's logs for errors and if I found a relevant Python stacktrace, I included it here as text in the "additional context" section.
Comment From: dosubot[bot]
Hi @marunrun! I'm Dosu and I’m helping the superset team.
The error happens because the Loading component is used as a Suspense fallback outside of the ThemeProvider context in the embedded SDK. Recent changes to the Loading component added theme integration, so it now requires ThemeProvider to be present higher in the tree. In the current setup, Suspense wraps RootContextProviders (which includes ThemeProvider), but the fallback (Loading) is rendered outside of these providers, causing useTheme() to fail with a missing ThemeContext error.
To fix this, you need to restructure your component hierarchy so that ThemeProvider (or RootContextProviders) wraps Suspense, ensuring the fallback also has access to the theme context. This architectural issue is confirmed in the code and recent discussions—see here for details and the code reference.
In short: move ThemeProvider above Suspense, or wrap the fallback in ThemeProvider, so Loading can access the theme context.
To reply, just mention @dosu.
How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other
Comment From: rusackas
This may be a version mismatch between Superset and the Embedded SDK. Which Embedded SDK version are you using?