@airma/react-state
Advanced tools
Comparing version 15.4.0 to 15.4.1
@@ -1,2 +0,2 @@ | ||
import { AirModelInstance, AirReducer, HoldCallback } from '@airma/core'; | ||
import { AirModelInstance, AirReducer, FactoryHolder } from '@airma/core'; | ||
import { FC, ReactNode } from 'react'; | ||
@@ -58,2 +58,2 @@ | ||
T extends Array<any> | ((...args: any) => any) | Record<string, any> | ||
>(requireFn: (factory: HoldCallback) => T): T; | ||
>(requireFn: (factory: FactoryHolder) => T): T; |
{ | ||
"name": "@airma/react-state", | ||
"version": "15.4.0", | ||
"version": "15.4.1", | ||
"module": "dist/index.js", | ||
@@ -29,2 +29,3 @@ "typings": "index.d.ts", | ||
"state-management", | ||
"react-query support", | ||
"closures", | ||
@@ -41,3 +42,3 @@ "state", | ||
"react-dom": ">=16.8.0", | ||
"@airma/core": "^15.4.0" | ||
"@airma/core": "^15.4.1" | ||
}, | ||
@@ -44,0 +45,0 @@ "devDependencies": { |
@@ -446,13 +446,13 @@ [![npm][npm-image]][npm-url] | ||
The methods from `useModel` returns is persistent, so, you can pass it to a memo component directly, it can improve your app performance. | ||
The methods from `useModel` instance is persistent, so, you can pass it to a memo component directly, it can improve your app performance. | ||
## Update data out of model function | ||
## Work with closure data | ||
Yes, the methods are persistent, but the model function can work with closure data too, when instance method is called, the result will be passed into the newest model function immediately to refresh instance. | ||
Yes, the methods are persistent, but you still can use closure data in the model function, it updates everytime, when the instance is refreshing. | ||
## Security for reducing state | ||
The API from `useTupleModel`(without onChange) like `useModel`, `useRefreshModel` are secure for state update. The state is outside of react system, so every update from methods is a secure reducing process. If you want to use `useState` to replace its job, you have to call it like: `setState((s)=>s+1)`. | ||
The API from `useTupleModel`(without onChange) like `useModel`, `useRefreshModel`, `useRequiredModel` are secure for state update. The state is outside of react system, so every update from methods is a secure reducing process. If you want to use `useState` to replace its job, you have to call it like: `setState((s)=>s+1)`. | ||
## typescript check | ||
## Typescript check | ||
@@ -465,2 +465,6 @@ `@airma/react-state` is a typescript support library, you can use it with `typescript` for a better experience. | ||
## Async state management | ||
You can not use async method with `@airma/react-state`, and we will not support async method in future, we suggest you works the async state with [react-query](https://tanstack.com/query/v4), you can use `useRefresh` or `useRefreshModel` to adapt the async state management. | ||
## End | ||
@@ -467,0 +471,0 @@ |
22491
472
Updated@airma/core@^15.4.1