2022-04-12 09:46:25 +07:00
|
|
|
import { Button } from "antd";
|
|
|
|
import React from "react";
|
|
|
|
import "./App.less";
|
2022-04-09 17:10:42 +07:00
|
|
|
|
|
|
|
function App() {
|
2022-04-12 09:46:25 +07:00
|
|
|
const [coms, setComs] = React.useState<any>([]);
|
|
|
|
|
|
|
|
const onCreate = () => {
|
|
|
|
setComs([
|
|
|
|
...coms,
|
|
|
|
{ id: coms.length * Math.random(), text: `New: ${Math.random()}` },
|
|
|
|
]);
|
|
|
|
};
|
|
|
|
|
|
|
|
const onRemove = (com: any) => {
|
|
|
|
setComs(coms.filter((c: any) => c.id !== com.id));
|
|
|
|
};
|
|
|
|
|
2022-04-09 17:10:42 +07:00
|
|
|
return (
|
|
|
|
<div className="App">
|
|
|
|
<header className="App-header">
|
2022-04-12 09:46:25 +07:00
|
|
|
<>Hello World</>
|
|
|
|
<Button onClick={onCreate} type={"primary"}>
|
|
|
|
Create me
|
|
|
|
</Button>
|
|
|
|
{coms.map((com: any) => (
|
|
|
|
<div key={com.id}>
|
|
|
|
<Button onClick={() => onRemove(com)}>{com.text}</Button>
|
|
|
|
</div>
|
|
|
|
))}
|
2022-04-09 17:10:42 +07:00
|
|
|
</header>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default App;
|