Comments (2)
Problem
Steps To Reproduce
Steps to reproduce the behavior:
fn main() { launch(client_mod::client_lib::Client); } pub fn Client() -> Element { println!("Client"); spawn(async move { // do some async things here } }
- I found that if something changed, the
Client(main App component)
will be rendered again, so theClient
will be printed many times. So that the spawn will generate many times.Expected behavior Is there a way could spawn new thread in
fn main
or other places, so I could just spawn a new thread once just like launch().Screenshots
If applicable, add screenshots to help explain your problem.
Environment:
- Dioxus version: 0.5.1
- Rust version: 1.7.75
- OS info: MacOS
- App platform:
desktop
We have use_future, use_effect, and use_hook depending on how much abstraction you need.
https://docs.rs/dioxus-hooks/latest/dioxus_hooks/fn.use_future.html
https://docs.rs/dioxus-hooks/latest/dioxus_hooks/fn.use_effect.html
https://docs.rs/dioxus-core/0.5.1/dioxus_core/fn.use_hook.html
from dioxus.
@jkelleyrtp thanks for the reply. but I found that to use the spawn() in the top element fn() could solve the problem. We should move the values that would be rerendered in the child component.
from dioxus.
Related Issues (20)
- Assigning a port number when using `dx serve --port [number]` on fullstack is not respected. HOT 2
- Ctrl/cmd click does not open in a new tab/window
- Dioxus-cli ignores env variables in `.cargo/config.toml` HOT 2
- pointermove events on Windows crash with InvalidType HOT 3
- [Desktop] Hot reloading does not work in the "tailwind" sample
- question: custom rendering to arbitrary wayland surface HOT 3
- Hydration error when using use_server_future in certain contexts in Fullstack
- Docs have a couple outdated examples
- Add `-p package` option to Dioxus CLI HOT 1
- Rerender fails when rendering an iterable with `None` elements inside
- how to send channel to child component HOT 8
- `use_reactive` inside `use_memo` causes infinite re-renders HOT 2
- `rsx` macro should prevent any children in self-closing elements
- Provide type checking support for HTML attribute values in `rsx` macro
- HTML String into rsx! HOT 1
- Update TailwindCSS Example Project HOT 2
- Add support for attaching event listeners to the global window HOT 2
- Hot reload doesn't turn off when using `--hot-reload=false`
- Assets in Dioxus build are "unpacked" from the original directory
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dioxus.