dash-mantine-components: [bug] Issue with dmc.Notification when switching pages on DMC 1.0+
Another issue I am noticing upon upgrading my DMC from 0.15.3 to 1.0 or 1.1, is an issue with dmc Notifications in my multipage DMC app. On my first page, there are callbacks that yield a dmc.Notification to a div. Here is an example of one notification:
within AppShellMain():
html.Div(
id="notifications-container",
)
callback:
Output("notifications-container", "children", allow_duplicate=True),
...
return dmc.Notification(
title="Success",
message=f"Opened experiment: {title}",
color="green",
action="show",
autoClose=2000,
icon=DashIconify(icon="ic:round-check-circle"),
)
app.py where i have the notification provider setup:
dmc.MantineProvider(
children=[
dmc.NotificationProvider(position="bottom-right"),
html.Div(id="notifications-container"),
dmc.AppShell(
id="app-shell",
children=[
app_header,
app_navbar,
html.Div(id="app-content", children=[dash.page_container]),
],
I’m noticing in DMC1.0/1.1 that when I go to other pages before that Notification autocloses, I get an error that crashes the page once the Notification autocloses. It doesn’t really matter which page I go to (except if I stay on the original page and wait for it to close and then there is no issue), I get a similar error and it lists out a large Json-like structure (attached below is for one page) that maps to whatever is on that page. Running my same exact code on DMC 0.15.3 never gave me this issue. Importantly, when I disable the Notifications from the app, I don’t have this issue anymore. I am using Dash 2.18.2.
(This error originated from the built-in JavaScript code that runs Dash apps. Click to see the full stack trace or open your browser's console.)
Error: An object was provided as `children` instead of a component, string, or number (or list of those). Check the children property that looks something like:
{
"props": {
"children": [
{
"props": {
"children": [
{
"props": {
"children": {
"props": {
"children": [
null,
{
"props": {
"children": {
"props": {
"action": "hide"
}
}
}
}
]
}
}
}
}
]
}
}
]
}
}
at validateComponent (http://127.0.0.1:8050/_dash-component-suites/dash/dash-renderer/build/dash_renderer.v2_18_2m1733601907.dev.js:3342:11)
at BaseTreeContainer.getComponent (http://127.0.0.1:8050/_dash-component-suites/dash/dash-renderer/build/dash_renderer.v2_18_2m1733601907.dev.js:4149:79)
at BaseTreeContainer.render (http://127.0.0.1:8050/_dash-component-suites/dash/dash-renderer/build/dash_renderer.v2_18_2m1733601907.dev.js:4328:19)
at finishClassComponent (http://127.0.0.1:8050/_dash-component-suites/dash/deps/react-dom@18.v2_18_2m1733601908.2.0.js:19762:33)
at updateClassComponent (http://127.0.0.1:8050/_dash-component-suites/dash/deps/react-dom@18.v2_18_2m1733601908.2.0.js:19708:26)
at beginWork (http://127.0.0.1:8050/_dash-component-suites/dash/deps/react-dom@18.v2_18_2m1733601908.2.0.js:21621:18)
at beginWork$1 (http://127.0.0.1:8050/_dash-component-suites/dash/deps/react-dom@18.v2_18_2m1733601908.2.0.js:27436:16)
at performUnitOfWork (http://127.0.0.1:8050/_dash-component-suites/dash/deps/react-dom@18.v2_18_2m1733601908.2.0.js:26570:14)
at workLoopSync (http://127.0.0.1:8050/_dash-component-suites/dash/deps/react-dom@18.v2_18_2m1733601908.2.0.js:26476:7)
at renderRootSync (http://127.0.0.1:8050/_dash-component-suites/dash/deps/react-dom@18.v2_18_2m1733601908.2.0.js:26444:9)
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 18 (3 by maintainers)
@olincb Thanks for adding to this issue - it’s likely related.
The odd thing is that if you wrap the return of the 3rd callback so it’s a single component, it seems to fix the issue. The error message in dash 2 was better than in dash 3. I think it should work either way, and your example works in dash 2 and dmc 0.15
Try this:
It’s not necessary to import the files from the pages folder like that because Pages automatically does that for you. In your case, it looks like you have set
pages folder = ''so it’s required . I typically put thedash.register_page(__name__)in each file in the pages folder, then you don’t have to manage the name. Plus you don’t need to specify thelayout=page1.layoutbecause it automatically uses thelayoutfrom the file. Lots of sample apps here: https://github.com/AnnMarieW/dash-multi-page-app-demos@BSd3v I can’t share the app.py publicly on here, but upon investigation further… i think I resolved it. I forgot I have a callback that serves the layout to
page-contentupon change in url. I’ve now put the notification div like this and I don’t have the issue anymore on Dash2 or Dash3. Why did I not encounter this issue in DMC <=0.15.3?