Nondeterministic Programming Methodology
Meet npm Pro: unlimited public & private packages + package-based permissions.Learn more »

region-core

9.2.4 • Public • Published

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 | 中文

Package Version Docs Description
region-core version The core of Region: set, load & useProps
region-shortcut version Wrapped core with global set, load & useProps
region-form version RegionForm extends Region: bindWith any ant-design form item

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();
  const { loading, error, fetchTime, value } = region.useProps();
 
  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.

Install

npm i region-core

DownloadsWeekly Downloads

49

Version

9.2.4

License

MIT

Unpacked Size

52.8 kB

Total Files

47

Last publish

Collaborators

  • avatar