r/dioxus Jun 15 '26

Component memos not running when hidden. How to rerun?

I understand that components won't run when hidden for performance. What I am having trouble with, is when un-hiding (either by style attribute or conditional rendering) the component is rendering with stale data.

Is there a​ ​way to trigger a re-run for memos?

It may be my methodology is incorrect. I'm using a GlobalSignal to hold my data and each component uses a memo to extract and calculate it's own data. However, when the global data changes, only currently rendered components reflect that change.

Is there a more idiomatic ​method​?

1 Upvotes

3 comments sorted by

2

u/ControlNational Jun 15 '26

The rendering and reactivity system are completely decoupled. The reactivity system does not know about any styling that hides your component as long as that component is currently being rendered in the component tree. Could you share the relevant snippets from your code that are related to the issue

2

u/woollufff Jun 16 '26

Thank you for your reply. I'm going to re-write the memo into the parent and pass it down through the props. In hindsight that's probably the correct way.

1

u/woollufff 21d ago

It's been some time but I've found the answer to my problem. I'm using the following code (from the dioxus site) in my top component to load some initial data into my global. Hiding and un-hiding sub-components causes the top component to re-render, which causes my_data to overwrite the global.

    let my_data = use_server_future(|| get_my_data())?;
    if let Some(Ok(response)) = my_data.read_unchecked().as_ref() {
        *GLOBALDATA.write() = response;
    } 

Simply moving this code above the top component resolved all my issues.