marmelab / react-admin

A frontend Framework for single-page applications on top of REST/GraphQL APIs, using TypeScript, React and Material Design
http://marmelab.com/react-admin
MIT License
25.04k stars 5.27k forks source link

Tiny bug in Advanced Tutorial "Custom Forms and UI for related records" error handling #6287

Open LucusWebsites opened 3 years ago

LucusWebsites commented 3 years ago

Took me a while to figure out, I am using:

https://codesandbox.io/s/react-admin-v3-advanced-recipes-quick-createpreview-voyci?file=/src/comments/PostQuickCreateButton.js

    ...
    const handleSubmit = async values => {
        create(
            { payload: { data: values } },
            {
                onSuccess: ({ data }) => {
                    setShowDialog(false);
                    // Update the comment form to target the newly created post
                    // Updating the ReferenceInput value will force it to reload the available posts
                    form.change('post_id', data.id);
                    onChange();
                },
                onFailure: ({ error }) => { // <----- should be onFailure: (error) => (without the curly braces)
                    notify(error.message, 'error');
                }
            }
        );
    };
    ...
djhi commented 3 years ago

Thanks for the report

WiXSL commented 2 years ago

@djhi. This is a bug in a code sandbox related to one of the articles. Could you change it?