Не уверен, так как описание было написано неправильно, но я предполагаю, что вы хотите видеть теги ниже в порядке, а не то, как они помещаются в поисковую информацию A или B. Здесь я бы добавил еще одну переменную состояния и поставил все детали в него.
import React from "react";
import "antd/dist/antd.css";
import { Input, Tag } from "antd";
const { Search } = Input;
class SearchInputs extends React.Component {
state = {
tagsA: [],
tagsB: [],
allTags: []
};
onCloseTagA = (e, i) => {
e.preventDefault();
this.setState({
tagsA: this.state.tagsA.filter((_, index) => index !== i),
allTags: this.state.allTags.filter((_, index) => index !== i)
});
};
onCloseTagB = (e, i) => {
e.preventDefault();
this.setState({
tagsB: this.state.tagsB.filter((_, index) => index !== i),
allTags: this.state.allTags.filter((_, index) => index !== i)
});
};
handleSearchA = value => {
console.log("The value", value);
const { tagsA, allTags } = this.state;
tagsA.push(value);
allTags.push(value);
this.setState({ tagsA, allTags });
};
handleSearchB = value => {
const { tagsB, allTags } = this.state;
tagsB.push(value);
allTags.push(value);
this.setState({ tagsB, allTags });
};
render() {
const { allTags } = this.state;
return (
<div
style={{
margin: "50px auto",
display: "flex",
flexDirection: "column"
}}
className="search-input-main"
>
<div style={{ display: "flex" }}>
<div style={{ margin: "50px" }} className="search-input-a">
Input A
<Search
placeholder="input search text"
onSearch={this.handleSearchA}
style={{ width: 200 }}
/>
</div>
<div style={{ margin: "50px" }} className="search-input-b">
Input B
<Search
placeholder="input search text"
onSearch={this.handleSearchB}
style={{ width: 200 }}
/>
</div>
</div>
<div>Tags of A and B</div>
<div style={{ display: "flex" }}>
{allTags.map((tag, i) => (
<Tag
style={{ margin: "5px" }}
key={i}
closable
onClose={e => this.onCloseTagB(e, i)}
color="#f50"
>
{tag}
</Tag>
))}
</div>
</div>
);
}
}
export default SearchInputs;