Conway's Game of Life as a React web app
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Cell.tsx 362B

1234567891011121314151617181920
  1. import React from 'react';
  2. interface Props {
  3. x: number;
  4. y: number;
  5. alive?: boolean;
  6. toggle: (x: number, y: number) => void;
  7. }
  8. const Cell = (props: Props) => {
  9. const { alive, toggle, x, y } = props;
  10. return (
  11. <span
  12. onClick={() => toggle(x, y)}
  13. className={`cell ${alive ? 'alive' : 'dead'}`}
  14. ></span>
  15. );
  16. };
  17. export default Cell;