pub fn use_ref_set_as<T: 'static + ?Sized>(value: Rc<T>) -> MutableRefRc<T>
Expand description

value will be the initial value. And in each render, if value changes, the MutableRefRc will be set as it.

let value: Rc<i32> = get_value();
react::use_ref_set_as(value);

The above rust code is equivalent to js code:

const value = getValue();
const refValue = React.useRef(value);
if (refValue.current != value) {
    refValue.current = value;
}