Skip to content
Advertisement

antd wrapping custom input with auto-complete cause: Cannot read property ‘value’ of undefined

In antd with react, If I’ve something like the below, everything works fine:

JavaScript

And that some intermediate component looks like this:

JavaScript

Everything works fine, until, I try to add AutoComplete

When I wrap the intermediate component with AutoComplete, like:

JavaScript

Then on changing or giving input to intermediate component cause error. Saying:

JavaScript

Complete trace is something like:

JavaScript

And the funny part is, console.log(`${event.target.value}--/`); logs the key pressed.

Advertisement

Answer

Solution:

JavaScript

I guess you should NOT write if (onChange) onChange(event.target.value); because inner onChange function needs event argument, not value.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement