You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The problem arises from a situation where the derived function never calls get (for whatever reason) which prevents a subscription from being created. The lack of a subscription prevents the property from being deleted which then prevents new calls to derive because the property is already defined.
Is this silly? Yes.
Was this hard to debug. Also yes. 😄
Property deletion should probably be decoupled from the existence of a subscription, especially since I see some async subscriptions being handled in the derive code which could possibly introduce a situation where underive is called before the async value resolves which would result in a similar error.
Link to reproduction
derive({myProperty(get){return123;// NOTE: Not using `get` which does not create a dependency.}},{proxy: myProxy})underive(myProxy,{delete: true,keys: ['myProperty'])// Throws Error: object property already defined
Pardon the lack of a codesandbox repro as the problem seemed pretty straight forward. I can make one if you really need one though.
Check List
Please do not ask questions in issues.
I've already opened a discussion before opening this issue, or already discussed in other media.
Transferred from: pmndrs/valtio#685 by @dlindahl
Summary
Calling
underive
withdelete: true
does not delete the derived property value unless there is a dependency.derive
subscribes to the dependencies defined within thederive
function.underive
withdelete: true
loops through all of the dependencies.Set
to delete later.proxyObject
.The problem arises from a situation where the derived function never calls
get
(for whatever reason) which prevents a subscription from being created. The lack of a subscription prevents the property from being deleted which then prevents new calls toderive
because the property is already defined.Is this silly? Yes.
Was this hard to debug. Also yes. 😄
Property deletion should probably be decoupled from the existence of a subscription, especially since I see some async subscriptions being handled in the
derive
code which could possibly introduce a situation whereunderive
is called before the async value resolves which would result in a similar error.Link to reproduction
Pardon the lack of a codesandbox repro as the problem seemed pretty straight forward. I can make one if you really need one though.
Check List
Please do not ask questions in issues.
I've already opened a discussion before opening this issue, or already discussed in other media.Please include a minimal reproduction.
I've added a link to a typescript playground or codesandbox with a minimal reproduction.The text was updated successfully, but these errors were encountered: