1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
use mem;
use crate;
/// Track the previous and current values of a reactive value.
///
/// This hook returns a `State<(T, T)>` where the first element is the previous value
/// and the second is the current value. Useful for animations or effects that need to
/// transition between values.
///
/// # Example
///
/// ```rust,no_run
/// # use freya::prelude::*;
/// fn app() -> impl IntoElement {
/// let value = use_state(|| 0);
/// let values: State<(i32, i32)> = use_previous_and_current(value);
///
/// rect().child(format!(
/// "Previous: {}, Current: {}",
/// values.read().0,
/// values.read().1
/// ))
/// }
/// ```