antd design import Import.Search issue

425 views Asked by At

I followed the Input.Search example here https://ant.design/components/input/

import { Input } from 'antd';
const Search = Input.Search;

ReactDOM.render(
   <Search placeholder="input search text" onSearch={value => console.log(value)} />
, mountNode);

I got the following error:

Uncaught Error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: undefined

Any idea why?

It works just fine if I used the <Input .../> component. Why does <Input.Search .../> break?

2

There are 2 answers

0
benjycui On BEST ANSWER

Input.Search is imported after [email protected], see: https://ant.design/changelog#2.5.0

0
Force Bolt On

To import Search from ant design Input your code is wrong.

The correct syntax to Import Search is Given below:-

const {Search} = Input;