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

react-patty

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-patty

React state management patterns as a library.

latest
Source
npmnpm
Version
0.0.6
Version published
Maintainers
1
Created
Source

React Patty

A tiny React state abstraction based on common patterns found in React applications.

Guiding principles:

  • Vanilla React: States should live in React's useState / useReducer. No external stores allowed.
  • No bad patterns: No skipping useEffect / useCallback / useMemo dependencies.
  • DevX focused: Simple + typed APIs, devtools integration.

‼️ Forward compatibility with future React features is the top priority.

Preview

Counter

import {createState} from 'react-patty/sync';

const Counter = createState(0, (prev, action) => {
  switch (action.type) {
    case 'INCREMENT':
      return prev + 1;
    case 'DECREMENT':
      return prev - 1;
    default:
      return prev;
  }
});

reactRoot.render(
  <Counter.Provider>
    <App />
  </Counter.Provider>
);

import {useValue, useDispatch} from 'react-patty';

function useCounter() {
  const dispatch = useDispatch(Counter);
  return {
    value: useValue(Counter),
    increment: () => dispatch({type: 'INCREMENT'}),
    decrement: () => dispatch({type: 'DECREMENT'}),
  };
}

FAQs

Package last updated on 25 Nov 2021

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