We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
I've run into a case where apply fails when applying the inverse patchset generated by create. Take the following code example
apply
create
const parentId = "parent"; const childId = "child"; const myObj = { [parentId]: { name: "parent", children: [childId] }, [childId]: { name: "child" }, }; const [newState, patchset, inverse] = create( myObj, (draft) => { // delete children while (draft[parentId].children.length) { const id = draft[parentId].children[0]; draft[parentId].children.splice(0, 1); delete draft[id]; // delete child object } // delete parent delete draft[parentId]; }, { enablePatches: { arrayLengthAssignment: false } } ); const reverted = apply(newState, inverse); // throws an error
When trying to apply inverse to newState, apply throws the following error:
inverse
newState
Cannot apply patch at 'parent/children/0'
Expected The inverse patchset is correctly generated and applied.
Note Reversing the inverse patchset in this case correctly applies it.
The text was updated successfully, but these errors were encountered:
hi @michaelhabibi , thanks for reporting the issue. I will fix it later.
Sorry, something went wrong.
Thank you again for reporting this issue.
We're pleased to inform you that the fix for this issue has been implemented and is now available in version v1.0.10, which has been released.
Thank you for such a quick turnaround! Confirming the fix works 👍
No branches or pull requests
I've run into a case where
apply
fails when applying the inverse patchset generated bycreate
. Take the following code exampleWhen trying to apply
inverse
tonewState
,apply
throws the following error:Expected
The inverse patchset is correctly generated and applied.
Note
Reversing the
inverse
patchset in this case correctly applies it.The text was updated successfully, but these errors were encountered: