I have the following code
I am trying to do the following. When the user types something in input it should be added into my array onBlur. That part was working well. Now besides adding to the array I want it automatically to be selected. How can Iimplement that?
import React, { useState } from "react";
import "antd/dist/antd.css";
import "./index.css";
import { Select } from "and";
const { Option } = Select;
const arr = ["1", "2", "3"];
const App = () => {
const [data, setData] = useState(arr);
return (
<>
<Select
mode="tags"
size={"large"}
placeholder="Please select"
style={{
width: "100%"
}}
>
{data?.map((el) => (
<Option key={el} value={el}>
{el}
</Option>
))}
</Select>
<input onBlur={(e) => setData([...data, e.target.value])} />
</>
);
};
export default App;
Please help me to resolve that problem.