DioxusLabs / dioxus

Fullstack app framework for web, desktop, mobile, and more.
https://dioxuslabs.com
Apache License 2.0
21.51k stars 828 forks source link

[Bug] Using Context with Suspense Throws a Warning #3209

Open wiseaidev opened 1 day ago

wiseaidev commented 1 day ago

Hiya 👋,

When using the use_context hook in a full-stack setup, I occasionally encounter a warning indicating that the hook is being called twice. It seems this happens because Suspense renders the component twice.

The warning doesn’t appear consistently, but it does pop up often enough to be concerning.

Opening this bug report to track the issue.

Best

ealmloff commented 1 day ago

Calling use_context multiple times when running a component shouldn't cause an issue. Components are supposed to rerun when they need to rerender. Can you provide more details about the issue from the template including: 1) The version of dioxus you are using 2) The panic message 3) The steps to reproduce the issue along with the code

wiseaidev commented 1 day ago

Calling use_context multiple times when running a component shouldn't cause an issue. Components are supposed to rerun when they need to rerender. Can you provide more details about the issue from the template including:

  1. The version of dioxus you are using
  2. The panic message
  3. The steps to reproduce the issue along with the code

Oops, my bad for not including the steps to reproduce (*/ω\) ! It was 3 a.m., and I was deep in the Dioxus rabbit hole. But, AFAIR, I was using use_context, and while poking around in the browser console, I spotted a warning about this issue on Firefox. Next time I run into it, I’ll be sure to update this issue (>ᴗ•)!