@veams/status-quo 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,10 +1,9 @@
1
- import { useMemo } from 'react';
1
+ import { useRef } from 'react';
2
2
  import { useStateSubscription } from './state-subscription.js';
3
3
  export function useStateFactory(stateFactoryFunction, params = []) {
4
- // eslint-disable-next-line react-hooks/exhaustive-deps
5
- const stateHandler = useMemo(() => stateFactoryFunction(...params), params);
6
- const actions = useMemo(() => stateHandler.getActions(), [stateHandler]);
7
- const state = useStateSubscription(stateHandler);
4
+ const stateHandler = useRef(stateFactoryFunction(...params));
5
+ const actions = useRef(stateHandler.current.getActions());
6
+ const state = useStateSubscription(stateHandler.current);
8
7
  return [state, actions];
9
8
  }
10
9
  //# sourceMappingURL=state-factory.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"state-factory.js","sourceRoot":"","sources":["../../src/hooks/state-factory.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAEhC,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAI/D,MAAM,UAAU,eAAe,CAC7B,oBAAoE,EACpE,SAAY,EAAkB;IAE9B,uDAAuD;IACvD,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,oBAAoB,CAAC,GAAG,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;IAC5E,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,CAAC;IACzE,MAAM,KAAK,GAAG,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAEjD,OAAO,CAAC,KAAK,EAAE,OAAO,CAAW,CAAC;AACpC,CAAC"}
1
+ {"version":3,"file":"state-factory.js","sourceRoot":"","sources":["../../src/hooks/state-factory.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAI/D,MAAM,UAAU,eAAe,CAC7B,oBAAoE,EACpE,SAAY,EAAkB;IAE9B,MAAM,YAAY,GAAG,MAAM,CAAC,oBAAoB,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC;IAC7D,MAAM,OAAO,GAAG,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;IAC1D,MAAM,KAAK,GAAG,oBAAoB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAEzD,OAAO,CAAC,KAAK,EAAE,OAAO,CAAW,CAAC;AACpC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veams/status-quo",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "The manager to rule states in frontend.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -1,4 +1,4 @@
1
- import { useMemo } from 'react';
1
+ import { useRef } from 'react';
2
2
 
3
3
  import { useStateSubscription } from './state-subscription.js';
4
4
 
@@ -8,10 +8,9 @@ export function useStateFactory<V, A, P extends unknown[]>(
8
8
  stateFactoryFunction: (...args: P) => StateSubscriptionHandler<V, A>,
9
9
  params: P = [] as unknown as P
10
10
  ) {
11
- // eslint-disable-next-line react-hooks/exhaustive-deps
12
- const stateHandler = useMemo(() => stateFactoryFunction(...params), params);
13
- const actions = useMemo(() => stateHandler.getActions(), [stateHandler]);
14
- const state = useStateSubscription(stateHandler);
11
+ const stateHandler = useRef(stateFactoryFunction(...params));
12
+ const actions = useRef(stateHandler.current.getActions());
13
+ const state = useStateSubscription(stateHandler.current);
15
14
 
16
15
  return [state, actions] as [V, A];
17
16
  }