I'm using react and antd.
I'm using antd's Input component.
I want to display an Error message at the bottom of the Input form if more than 10 characters are entered.
I want to use antd's errorMessage.
import React from "react";
import { Input } from "antd";
const App = () => {
const [value, setValue] = React.useState(null);
const [onSave, setOnSave] = React.useState(null);
const handleInputChange = React.useCallback((e) => {
setValue(Number(e.target.value));
}, []);
const onSaveBlur = React.useCallback(() => {
if (String(value).length < 10) {
setOnSave(true);
} else {
setOnSave(false);
}
}, [value]);
return (
<div className="App">
<h1>Hello CodeSandbox</h1>
<h2>Start editing to see some magic happen!</h2>
<Input
type="number"
value={value}
onChange={handleInputChange}
onBlur={onSaveBlur}
></Input>
</div>
);
};
export default App;