type ButtonProps = {
  log: (item: unknown) => void;
  onClick: (e: React.MouseEvent<HTMLButtonElement>) => void;
  title: string;
};

const Button: React.FC<ButtonProps> = ({ log, onClick, title }) => {
  return (
    <button
      onClick={(e) => {
        log(e);
        onClick(e);
      }}
    >
      {title}
    </button>
  );
};

function log(item: unknown) {
  console.log('Logger:', item);
}

type LoggerProps = {
  children: (logFn: (item: unknown) => void) => React.ReactNode;
};

const Logger: React.FC<LoggerProps> = ({ children }) => {
  return <>{children(log)}</>;
};

const App: React.FC = () => {
  return (
    <div>
      <Logger>
        {(log) => (
          <Button
            log={log}
            onClick={() => console.log('click handled')}
            title="Click me"
          />
        )}
      </Logger>
    </div>
  );
};

export default App;

