mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
use_future_with: simplify code a bit by using read-only use_memo rather than use_state (#3610)
* use_future_with: simplify code a bit by using read-only use_memo rather than use_state * use use_ref instead of use_memo_base --------- Co-authored-by: Elina <imelina@elina.website>
This commit is contained in:
parent
c5d486160c
commit
4faa150104
@ -94,8 +94,7 @@ where
|
|||||||
let output = use_state(|| None);
|
let output = use_state(|| None);
|
||||||
// We only commit a result if it comes from the latest spawned future. Otherwise, this
|
// We only commit a result if it comes from the latest spawned future. Otherwise, this
|
||||||
// might trigger pointless updates or even override newer state.
|
// might trigger pointless updates or even override newer state.
|
||||||
let latest_id = use_state(|| Cell::new(0u32));
|
let latest_id = use_ref(|| Cell::new(0u32));
|
||||||
|
|
||||||
let suspension = {
|
let suspension = {
|
||||||
let output = output.clone();
|
let output = output.clone();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user