DioxusLabs/docsite

`use_resource` is breaking if you access the page directly

gusinacio opened this issue · 1 comments

Problem

I'm trying to follow the documentation to access Data Fetching. My app could never work by accessing directly. I also noted that the documentation is not working as well. The router breaks as well (you can not access other pages via clicking it).

What is weird about it is that if you navigate to Data Fetching via another app-page, it doesn't break.

Steps To Reproduce

Steps to reproduce the behavior:

docsite.js:266 wasm-bindgen: imported JS function that was not marked as `catch` threw an error: Cannot read properties of undefined (reading 'listening')

Stack:
TypeError: Cannot read properties of undefined (reading 'listening')
    at RawInterpreter.run (https://dioxuslabs.com/assets/dioxus/snippets/dioxus-interpreter-js-e8d4f2300616f4bc/inline0.js:140:444)
    at https://dioxuslabs.com/assets/dioxus/docsite.js:1475:21
    at logError (https://dioxuslabs.com/assets/dioxus/docsite.js:257:18)
    at imports.wbg.__wbg_run_0d6c75f5df5eea8a (https://dioxuslabs.com/assets/dioxus/docsite.js:1474:62)
    at dioxus_web::mutations::<impl dioxus_web::dom::WebsysDom>::flush_edits::haf17ca5d822837c6 (https://dioxuslabs.com/assets/dioxus/docsite_bg.wasm:wasm-function[505]:0xf0682)
    at dioxus_web::launch::launch_virtual_dom::{{closure}}::hc448b40a9e4728ba (https://dioxuslabs.com/assets/dioxus/docsite_bg.wasm:wasm-function[291]:0x76750)
    at wasm_bindgen_futures::queue::Queue::new::{{closure}}::hf6f741d238108123 (https://dioxuslabs.com/assets/dioxus/docsite_bg.wasm:wasm-function[814]:0x11ac57)
    at wasm_bindgen::convert::closures::invoke1_mut::h84f5add805f3d75d (https://dioxuslabs.com/assets/dioxus/docsite_bg.wasm:wasm-function[3346]:0x16808c)
    at __wbg_adapter_57 (https://dioxuslabs.com/assets/dioxus/docsite.js:327:10)
    at real (https://dioxuslabs.com/assets/dioxus/docsite.js:286:20)
logError @ docsite.js:266
docsite.js:267 Uncaught TypeError: Cannot read properties of undefined (reading 'listening')
    at RawInterpreter.run (inline0.js:140:444)
    at docsite.js:1475:21
    at logError (docsite.js:257:18)
    at imports.wbg.__wbg_run_0d6c75f5df5eea8a (docsite.js:1474:62)
    at dioxus_web::mutations::<impl dioxus_web::dom::WebsysDom>::flush_edits::haf17ca5d822837c6 (docsite_bg.wasm:0xf0682)
    at dioxus_web::launch::launch_virtual_dom::{{closure}}::hc448b40a9e4728ba (docsite_bg.wasm:0x76750)
    at wasm_bindgen_futures::queue::Queue::new::{{closure}}::hf6f741d238108123 (docsite_bg.wasm:0x11ac57)
    at wasm_bindgen::convert::closures::invoke1_mut::h84f5add805f3d75d (docsite_bg.wasm:0x16808c)
    at __wbg_adapter_57 (docsite.js:327:10)
    at real (docsite.js:286:20)

Expected behavior

When accessing the website, it should fetch correctly using use_resource and not break the router.

Screenshots

If applicable, add screenshots to help explain your problem.

Environment:

  • Dioxus version: 0.5.0
  • Rust version: 1.75
  • OS info: MacOs
  • App platform: Fullstack

Questionnaire

  • I'm interested in fixing this myself but don't know where to start
  • I would like to fix and I have a solution
  • I don't have time to fix this right now, but maybe later

That error is likely caused by a hydration issue where the server and client render a slightly different page. I can't reproduce this issue running the doc site locally with dx serve, but I do see the error on the live page