use-logger

Log given values to console when component renders

Import

Usage

use-logger logs given values to the console each time component renders. Open devtools to see state changes in console:

import { useState } from 'react';
import { useLogger } from '@mantine/hooks';
import { Button } from '@mantine/core';

function Demo() {
  const [count, setCount] = useState(0);
  useLogger('Demo', [{ count, hello: 'world' }]);
  return <Button onClick={() => setCount((c) => c + 1)}>Update state ({count})</Button>;
}

Definition

function useLogger(componentName: string, props: any[]): any;