@bluelibs/smart
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

BlueLibs SMART

Smart is a simple tool which allows you to decouple state and logic from your components.

Goodies:

  • ✅ Uses React Hooks behind the scenes
  • ✅ Manage state and actions separately from your components
  • ✅ TypeScript auto-completion at every step
  • ✅ Ultra light-weight
  • ✅ Integration with Redux DevTools

Install

npm install --save @bluelibs/smart
import { Smart, smart } from "@bluelibs/smart";

// This is where you make api queries and this is where you set or update the state
class Counter extends Smart {
  state = {
    count: 0,
  };

  increment() {
    this.setState({ count: this.state.count + 1 });
  }
}

// Components just call the Counter and use `counter.state`
function Component() {
  const counter = useSmart(Counter);

  // Access to api.state
  // Ability to trigger api.increment()
}

smart(Counter)(Component);

Documentation

Click here to go to the documentation

Support

This package is part of BlueLibs family. If you enjoy this work please show your support by starring the main package. If not, let us know what can we do to deserve it, our feedback form is here

Readme

Keywords

none

Package Sidebar

Install

npm i @bluelibs/smart

Weekly Downloads

91

Version

1.0.5

License

MIT

Unpacked Size

32 kB

Total Files

21

Last publish

Collaborators

  • theodordiaconu