@prometheus-ags/prometheus-entity-management 1.2.0 → 1.2.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.
package/dist/index.js CHANGED
@@ -1180,10 +1180,11 @@ function useEntity(opts) {
1180
1180
  fetchRef.current = opts.fetch;
1181
1181
  const normalizeRef = React6.useRef(opts.normalize);
1182
1182
  normalizeRef.current = opts.normalize;
1183
- const data = zustand.useStore(useGraphStore, shallow.useShallow((state) => {
1183
+ const dataSelector = React6.useCallback((state) => {
1184
1184
  if (!id) return null;
1185
1185
  return state.readEntitySnapshot(type, id);
1186
- }));
1186
+ }, [id, type]);
1187
+ const data = zustand.useStore(useGraphStore, shallow.useShallow(dataSelector));
1187
1188
  const entityState = zustand.useStore(useGraphStore, React6.useCallback(
1188
1189
  (state) => state.entityStates[`${type}:${id}`] ?? EMPTY_ENTITY_STATE,
1189
1190
  [type, id]
@@ -1216,13 +1217,11 @@ function useEntityList(opts) {
1216
1217
  const normalizeRef = React6.useRef(opts.normalize);
1217
1218
  normalizeRef.current = opts.normalize;
1218
1219
  const listState = zustand.useStore(useGraphStore, React6.useCallback((state) => state.lists[key] ?? EMPTY_LIST_STATE, [key]));
1219
- const items = zustand.useStore(
1220
- useGraphStore,
1221
- shallow.useShallow((state) => {
1222
- const ids = state.lists[key]?.ids ?? EMPTY_IDS;
1223
- return ids.map((id) => state.readEntitySnapshot(type, id)).filter((x) => x !== null);
1224
- })
1225
- );
1220
+ const itemsSelector = React6.useCallback((state) => {
1221
+ const ids = state.lists[key]?.ids ?? EMPTY_IDS;
1222
+ return ids.map((id) => state.readEntitySnapshot(type, id)).filter((x) => x !== null);
1223
+ }, [key, type]);
1224
+ const items = zustand.useStore(useGraphStore, shallow.useShallow(itemsSelector));
1226
1225
  const doFetch = React6.useCallback((params = {}) => {
1227
1226
  if (!enabled) return;
1228
1227
  fetchList({ type, queryKey, mode, fetch: fetchRef.current, normalize: normalizeRef.current }, params, getEngineOptions(), false);