#Have a lifetime problem
1 messages · Page 1 of 1 (latest)
well use_state does in fact use an FnOnce, unlike some other hooks, but the result (T: 'static) is stored away in the component, so you cannot store a props: & in the component, as that & (rust compiler gives it a name to explain the error for you, so it becomes &'1) lives only as long as the call does
if you really want to store the props struct in that state, try use_state(|| _props.clone()) (but ensure OrderInputProp is Clone) - this will turn a &OrderInputProp into a OrderInputProp, which does not have any lifetime limitations to it
i have tryed with .clone() but it do not work.
What is the new error?