<div id="root" class="panel center"></div>
<!-- layout jump solved in this codepen https://codepen.io/GreenSock/pen/MWmqzjE -->
.app {
  padding: 10px;
}

.box {
  margin: 10px 10px 0 0;
}

.boxes {  
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
}
const { useRef, useState } = React;

function App() {    
  
  const [items, setItems] = useState(() => [
    { id: 0, color: "blue" },
    { id: 1, color: "red" },
    { id: 2, color: "purple" }
  ]);
  
  const removeItem = (value) => {
    setItems(prev => prev.filter(item => item !== value));
  }
  
  const remove = (item, target) => {
    gsap.to(target, {
      opacity: 0,
      onComplete: () => removeItem(item)
    });
  };
  
  return (
    <div className="app boxes">
      {items.map((item) => (
        <div 
          className={`box ${item.color}`} 
          key={item.id} 
          onClick={(e) => remove(item, e.currentTarget)}
        >
          Click Me
        </div>
      ))}
    </div>
  );
}

ReactDOM.render(<App />, document.querySelector("#root"));
View Compiled

External CSS

  1. https://codepen.io/GreenSock/pen/gOWxmWG.css

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/react/17.0.2/umd/react.production.min.js
  2. https://cdnjs.cloudflare.com/ajax/libs/react-dom/17.0.2/umd/react-dom.production.min.js
  3. https://unpkg.co/gsap@3/dist/gsap.min.js