Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read properties of undefined when deleting child and then parent #41

Closed
Ciccio99 opened this issue Nov 30, 2023 · 1 comment · Fixed by #42
Closed

Cannot read properties of undefined when deleting child and then parent #41

Ciccio99 opened this issue Nov 30, 2023 · 1 comment · Fixed by #42
Labels
help wanted Extra attention is needed

Comments

@Ciccio99
Copy link

This issue affects valtio-yjs specifically, as it functions correctly with vanilla valtio.

Here is a simplified example of the issue: codesandbox

I have an object structure similar to this:


type child = {
  id: string;
  parent: string;
};

type parent = {
  children: {
    [id: string]: child;
  };
};

type State = {
  parents: {
    [id: string]: parent;
  };
};

If I delete a child of a parent and then immediately delete the parent, then valtio-yjs throws an undefined error.

The use case for this logic is used when I'm deleting a child from a parent, and if the child is the last child in parent, then delete the parent.

This isn't a major issue, since you can get around this issue by checking if it's the last child and then just deleting the parent directly. However, seeing as this is functional with vanilla valtio, It should probably work with valtio-yjs as well.

@dai-shi dai-shi added the help wanted Extra attention is needed label Dec 1, 2023
raineorshine added a commit to raineorshine/valtio-yjs that referenced this issue Dec 1, 2023
raineorshine added a commit to raineorshine/valtio-yjs that referenced this issue Dec 1, 2023
raineorshine added a commit to raineorshine/valtio-yjs that referenced this issue Dec 1, 2023
dai-shi added a commit that referenced this issue Dec 2, 2023
@dai-shi
Copy link
Member

dai-shi commented Dec 2, 2023

Published https://www.npmjs.com/package/valtio-yjs/v/0.5.1, thanks to @raineorshine !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants