Open prodderman opened 12 months ago
Hi @raveclassic!
There is a problem with usePropertyFromProps - the atom changes after the render and at the moment of the react props change prop !== prop$.get():
usePropertyFromProps
prop !== prop$.get()
const Component = ({ prop }) => { const prop$ = usePropertyFromProps(prop) prop$.get() === prop // false at the moment of the props change }
Isn't it better to use the following implementation:
function usePropertyFromProps<Value>(value: Value): Property<Value> { const atomRef = useRef(newAtom(value)) atomRef.current.set(value) return atomRef.current }
Hi @raveclassic!
There is a problem with
usePropertyFromProps
- the atom changes after the render and at the moment of the react props changeprop !== prop$.get()
:Isn't it better to use the following implementation: