-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
First, thanks for providing this react version of the excellent changeset lib!
I was able to get it working except one issue which is when I want to manually add an error to the changeset as part of a try/catch handler.
When I add the error the component does not recognize the change and thus does not rerender, but if I manually trigger a rerender via e.g. hacked useReducer() trick, the component will update and show the error.
if (changeset.isValid) {
await changeset.save();
try {
await submit(changeset.data);
} catch (err) {
await catchErrors(err, changeset);
// force rerender.
// update(); <-- without this hacked forced update the error that's added in catchErrors() will not trigger a re-render of the component.
}
}
export function catchErrors(errors, changeset) {
if (errors.message) {
changeset.addError('nonFieldErrors', {
value: 'nonFieldErrors',
validation: [errors.message],
});
}
}
Is there a better way to tell React to rerender when an error is added to the changeset?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels