Comments (8)
That works great. I spent an hour trying to find out why it's not logging haha.
I think that solved my issue. I'll close this issue. Thank you for the fast respond!
from freya.
That's exactly what use_node
/use_node_signal
do
from freya.
https://github.com/marc2332/freya/blob/main/examples/min_max_sizing.rs
from freya.
Hmm okay. I was having trouble trying to log out the size of the node inside my use_effect
. Turns out it only trigger when you include the size in the rendering code.
fn app() -> Element {
let (node_ref, size) = use_node_signal();
use_effect({
move || {
println!("{:?}", size().area.width()); // This won't print every time I resize
}
});
rsx!(
rect {
width: "50%",
height: "50%",
min_width: "200",
min_height: "100",
max_width: "300",
max_height: "250",
background: "black",
reference: node_ref,
label {
color: "white",
// "Size: {size().area.width()}x{size().area.height()}"
}
}
)
}
fn app() -> Element {
let (node_ref, size) = use_node_signal();
use_effect({
move || {
println!("{:?}", size().area.width()); // This will print
}
});
rsx!(
rect {
width: "50%",
height: "50%",
min_width: "200",
min_height: "100",
max_width: "300",
max_height: "250",
background: "black",
reference: node_ref,
label {
color: "white",
"Size: {size().area.width()}x{size().area.height()}"
}
}
)
}
from freya.
Hmm okay. I was having trouble trying to log out the size of the node inside my
use_effect
. Turns out it only trigger when you include the size in the rendering code.fn app() -> Element { let (node_ref, size) = use_node_signal(); use_effect({ move || { println!("{:?}", size().area.width()); // This won't print every time I resize } }); rsx!( rect { width: "50%", height: "50%", min_width: "200", min_height: "100", max_width: "300", max_height: "250", background: "black", reference: node_ref, label { color: "white", // "Size: {size().area.width()}x{size().area.height()}" } } ) }fn app() -> Element { let (node_ref, size) = use_node_signal(); use_effect({ move || { println!("{:?}", size().area.width()); // This will print } }); rsx!( rect { width: "50%", height: "50%", min_width: "200", min_height: "100", max_width: "300", max_height: "250", background: "black", reference: node_ref, label { color: "white", "Size: {size().area.width()}x{size().area.height()}" } } ) }
That is actually a Dioxus bug I believe
from freya.
Let me see if I can get around it
from freya.
@ZeroX-DG I can't fix it from Freya but there is a workaround for you I actually use in some places
Use use_memo
instead of use_effect
fn app() -> Element {
let (node_ref, size) = use_node_signal();
use_memo(move || {
println!("{:?}", size().area.width());
});
rsx!(
rect {
width: "50%",
height: "50%",
min_width: "200",
min_height: "100",
max_width: "300",
max_height: "250",
background: "black",
reference: node_ref,
label {
color: "white",
// "Size: {size().area.width()}x{size().area.height()}"
}
}
)
}
from freya.
Awesome 😄
from freya.
Related Issues (20)
- Signal panicking when being set in a separate thread HOT 8
- enhancement: Expose scale factor in PlatformInformation HOT 6
- bug: Queued events could be wrongly emitted to Elements whose ElementId (VirtualDOM ID) have been reused HOT 1
- enhancement: Placeholder text for `Input`
- enhancement: Close Window API
- enhancement: Run a weekly CI of freya against Dioxus to be aware of breaking changes
- enhancement: RSX Autocomplete improvements
- enhancement: Minimize and maximize from components HOT 1
- bug: Performances goes down the more text you highlight HOT 1
- idea: Process all the queued events at once without polling the virtual dom in between
- enhancement: Support synching the theme with the OS selected theme
- enhancement: Image optimizations in `NetworkImage`
- enhancement: Reactive Platform data
- enhancement: Reactive Window data
- enhancement: Support shift + click to select text
- enhancement: Remove text with Delete
- enhancement: Persisted routing in devtools
- enhancement: Expandable elements in the devtools inspector
- enhancement: Support `Switch` in `use_form`
- enhancement: Support `Slider` in `use_form`
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 freya.