0.10.0 • Published 3 years ago

@open-tech-world/react-state v0.10.0

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

React State

⚡ by Open Tech World

Build npm bundle size (scoped version)

A shared state management library for React.

Features

  • Simple API
  • No context providers
  • Components are re-rendered only when the selector value changes
  • It can shallow diff custom selector objects
  • It supports async actions
  • TypeScript support

Installation

Using npm

npm install @open-tech-world/react-state

Using Yarn

yarn add @open-tech-world/react-state

Usage

import { createState } from '@open-tech-world/react-state';

const useAppState = createState({});

function App() {
  const [state, setState] = useAppState((s) => s, { set: true });
  console.log(state);

  return (
    <>
      <button onClick={() => setState((s) => ({ obj: value }))}>
        Change State
      </button>
    </>
  );
}

Usage (TypeScript)

import { createState } from '@open-tech-world/react-state';

interface AppState {
  obj1: type1;
  obj2: type2;
}

const appState: AppState = { obj1: value, obj2: value };

const useAppState = createState(appState);

function App() {
  const [state, setState] = useAppState((s) => s, { set: true });
  console.log(state);

  return (
    <>
      <button onClick={() => setState((s) => ({ obj1: newValue }))}>
        Change State
      </button>
    </>
  );
}

Documentation

Please read the complete documentation at: https://react-app-state.pages.dev/

License

Copyright (c) 2021, Thanga Ganapathy (MIT License).

0.10.0

3 years ago

0.9.0

3 years ago

0.8.1

3 years ago

0.8.0

3 years ago

0.7.1

3 years ago

0.7.0

3 years ago

0.6.0

3 years ago

0.5.0

3 years ago

0.4.0

3 years ago

0.3.1

3 years ago

0.3.0

3 years ago

0.2.0

3 years ago

0.1.2

3 years ago

0.1.1

3 years ago

0.1.0

3 years ago