Search code examples
reactjsantd

Form antd onFinish not getting triggered


I have a onFinish function that modifies the values/json sent to the backend API.

Here is how it looks..

    const onFinish = formProps.onFinish!;

    formProps.onFinish = (values: any) => {
        // Ignore display only fields.
        

        ["a", "b"].forEach((k: string) => {
            delete values[k];
        });

        onFinish(values);
    };
    .
    .
    .
    .
    <Form {...formProps} layout="vertical" onFinish={onFinish}>

This is working perfectly fine in localhost where i use npm run dev. However - it does NOT work in dev environment where i run npm ci followed by npm run build

The console logs confirm that the onFinish is only being called in localhost and not in dev.

Interestingly console logs is that in the environment where this works (shown first below) - looks a bit different

works

in the environment where this does NOT work - i see the logs in a different format (shown second below)

does NOT work


Solution

  • This turned out to be a minifier issue. After changing the function name from onFinish to handleFinish - it started working.