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:
Léo Gaspard 2024-08-03 23:35:38 +02:00 committed by GitHub
parent c5d486160c
commit 4faa150104
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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();