Skip to content

Instantly share code, notes, and snippets.

@sashuk
Last active September 4, 2026 08:21
Show Gist options
  • Select an option

  • Save sashuk/ea0cd89820cacea4b7dacc5f65733534 to your computer and use it in GitHub Desktop.

Select an option

Save sashuk/ea0cd89820cacea4b7dacc5f65733534 to your computer and use it in GitHub Desktop.
Exercise

Exercise 1

const ServiceCard = React.memo(function ServiceCard({ service }) {
  return <ExpensiveVisualization service={service} />;
});

function Dashboard({ services, event }) {
  const updated = services.map((service) => ({
    ...service,
    lastEvent: service.id === event.serviceId ? event : service.lastEvent,
  }));

  return updated.map((service) => (
    <ServiceCard key={service.id} service={service} />
  ));
}

Exercise 2

const data = useStore((state) => ({
  cpu: state.services[id].cpu,
  memory: state.services[id].memory,
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment