JSPM

  • Created
  • Published
  • Downloads 19
  • Score
    100M100P100Q65713F
  • License MIT

region-core

Package Exports

  • region-core

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (region-core) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

region-core

version npm downloads codecov MIT License

region-core is a progressive View Model Management Framework. You can use it while using react state, redux, and benefit from it.

English | 中文

Get Started

  • install
npm i region-core
  • Create a Component with region
import { createRegion } from 'region-core';

const region = createRegion('initialValue');

const handleChange = e => region.set(e.target.value);

const Component = () => {
  const value = region.useValue();
  return <input value={value} onChange={handleChange} />;
};
  • Fetching data with region
import { createRegion } from 'region-core';

const region = createRegion();

const loadUser = region.loadBy(asyncFuncion);

// call loadUser in application lifecycle
loadUser({userId: 1});

const Component = () => {
  const value = region.useValue();
  const loading = region.useLoading();
  const error = region.useError();
  const fetchTime = region.useFetchTime();

  return <div>{value}</div>;
}

Docs

Document And Best Practices

Migrate Guide

ChangeLog

Request for Comments

Example

Online Example

git clone https://github.com/regionjs/region-core.git
cd example
npm i
npm start

SSR: NextJs with Region

Contribute

Feel free to raise issues and PR.