diff --git a/packages/hooks/src/usestate.rs b/packages/hooks/src/usestate.rs index 6e8070191..d9530ee8e 100644 --- a/packages/hooks/src/usestate.rs +++ b/packages/hooks/src/usestate.rs @@ -285,6 +285,12 @@ impl UseState { RefMut::map(slot, |rc| Rc::get_mut(rc).expect("the hard count to be 0")) } + + /// Convert this handle to a tuple of the value and the handle itself. + #[must_use] + pub fn split(&self) -> (&T, &Self) { + (&self.current_val, self) + } } impl Clone for UseState {