New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

react-hooks-logger

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-hooks-logger

Simple react hooks logger.

latest
Source
npmnpm
Version
1.0.2
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source




react-hooks-logger







npm i react-hooks-logger





image

Simple hooks logger. (Respect redux-logger and use-reducer-logger)

Maintainability

Usage

import { useReducer } from 'react-hooks-logger';

function reducer(state, action) {
  switch (action.type) {
    case 'count-up':
      return { count: state.count + action.payload.count }

    case 'count-down':
      return { count: state.count - action.payload.count }
  }
}
const initialState = { count: 0 };

const Demo = () => {
  const [state, dispatch] = useReducer(reducer, initialState);

  return (
<div>
      <button
        onClick={() =>
          dispatch({
            type: "count-up",
            payload: { count: 1 }
          })
        }
      >
        +
      </button>
      <button
        onClick={() =>
          dispatch({
            type: "count-down",
            payload: { count: 1 }
          })
        }
      >
        -
      </button>
      count: {state.count}
    </div>
  );
};

Dev Environment

Create custom hooks.

import { useReducer: _useReducer } from 'react';
import { useReducer: useReducerWithLog } from 'react-hooks-logger';

export const useMyReducer = 
  process.env.NODE_ENV === 'development' ? useReducerWithLog : _useReducer;

Import your hooks.

import { useReducer } from './useMyReducer';

...

Todo

  • Another Hooks API logger

Keywords

react

FAQs

Package last updated on 17 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts