react-global-state

Efficient and simple to use global state management for React, implemented with hooks, and spiced by useful data management functions (async retreival, caching, etc.)

OTHER License

Downloads
321
Stars
1
Committers
2

Bot releases are hidden (Show)

react-global-state - v0.14.2 Latest Release

Published by birdofpreyru 5 months ago

  • [#90] Optimization of useAsyncData() and useAsyncCollection() hooks — when instead of a promise provided loader returns data value directly, this value is immediately (synchronously) stored into the corresponding global state segment (envelope), without visiting its (re-)loading state (which is the state of envelope when waiting for the promise settlement in case when a promise is returned by the loader).
  • [#91] reload function in result objects returned by useAsyncData() and useAsyncCollection() hooks is now stable (does not change across re-renders of the hook's host component).
  • [#93] Update of dependencies.
react-global-state - v0.14.1

Published by birdofpreyru 6 months ago

  • Update of dependencies.
react-global-state - v0.14.0

Published by birdofpreyru 7 months ago

Breaking Changes

  • [#87] useGlobalState() — patches functional updates of the global state. Prior to this patch the update function was getting the old value (at the end of the last render), now it gets the current value (i.e. accounts for any state updates already done, and pending to be notified for triggering the next render).

Other Updates

react-global-state - v0.13.0

Published by birdofpreyru 8 months ago

Breaking Changes

  • Fixes a bug in useAsyncData() that was causing unnecessary data refresh on the hook mount if no deps option was used.

Misc Updates

  • [#80] Updates newAsyncDataEnvelope() function to accept optional second argument that allows to specify initial values for numRefs and timestamp fields in the created envelope.
  • [#81] Fixes broken links in the documentation.
  • Updates dependencies.
react-global-state - v0.12.0

Published by birdofpreyru 11 months ago

  • [#22] Fixes regressed issue with useGlobalState() usage for managed text inputs (invalid resets of the cursor position to the end).
  • Updates dependencies.
react-global-state - v0.11.0

Published by birdofpreyru 11 months ago

  • [#75] Upgrades the handling of deps option in useAsyncData() and useAsyncCollection() hook options. These dependencies are now tracked and compared per global state path, rather than just per a hook instance, thus avoiding unnecessary re-loads of related data.
  • [#74] Updates dependencies.
react-global-state - v0.10.0-alpha.7

Published by birdofpreyru 11 months ago

  • Adds an imperative reload handler to the object returned by useAsyncData() hook. It facilitates manipulation of async data in the global state from imperative code (like mouse event handlers, _etc.).
react-global-state - v0.10.0-alpha.6

Published by birdofpreyru 11 months ago

TypeScript:: Fixes types deduction in host projects (it was silently broken if the host project did not have @types/lodash package installed).

react-global-state - v0.10.0-alpha.5

Published by birdofpreyru 12 months ago

  • Returns withGlobalStateType method, instead of API interface and default exports.
  • Updates dependencies.
react-global-state - v0.10.0-alpha.4

Published by birdofpreyru almost 1 year ago

  • Drops withGlobalStateType() function, in favor of the special API interface.
  • Minor internal refactoring.
react-global-state - v0.10.0-alpha.3

Published by birdofpreyru about 1 year ago

  • TypeScript: Minor fixes in type definitions; it changed generic signatures of hook & function overloads that allow to enforce arbitrary types of their returned / accepted values.
  • Updates dependencies.
  • Officially supported Node versions now are: 8.18+ (maintenance); 20.8+ (LTS); 21.0+ (current).
react-global-state - v0.10.0-alpha.2

Published by birdofpreyru over 1 year ago

  • [#67] Fixes the build & NPM package setup broken in the previous v0.10.0-alpha.1 version.
  • [#66] README: Removes all content, beside the link to stand-alone Docusuarus documentation, and various badges.
react-global-state - v0.10.0-alpha.1

Published by birdofpreyru over 1 year ago

  • TypeScript support 🎉 See updated Documentation for details.

    The entire codebase was migrated to TypeScript as well, thus it may take a few more alpha releases to ensure the backward compatibility with JavaScript has not been broken, and every new TypeScript-specific feature works perfectly.

react-global-state - v0.9.3

Published by birdofpreyru over 1 year ago

  • Updates dependencies.
react-global-state - v0.9.2

Published by birdofpreyru almost 2 years ago

  • Updates dependencies.
react-global-state - v0.9.1

Published by birdofpreyru about 2 years ago

  • Updates dependencies.
react-global-state - v0.9.0

Published by birdofpreyru over 2 years ago

Breaking Changes

  • Requires React@18+.
  • Internal data inside GlobalState are now hidden in private fields.
  • The initial state provided to GlobalStateProvider is not deep-clonned anymore by the library, and it is just assumed to be non-mutatable. If you need to modify it after providing to the library, be sure to deep-clone it yourself.
  • Inside SSR rounds all calls to useGlobalState() hook return values from the initial state, instead of the current one. Thus, all state changes during an SSR pass will have effect in the next SSR pass, rather than (partially) in the current one. In particular, before this change useAsyncData() and useAsyncCollection() hooks reported "loading" state (if loading was initiated) in the very first pass, now they don't, which may slightly alter initial renders (resulting in "not-loaded" instead of the "loading" state) in case SSR was not completed.

Other Changes

  • Misc performance optimizations.
  • GlobalState's .get() method got an optional second argument, allowing to read value from the initial state, and to set initial (default) value at the given path.
  • Update of dependencies.
react-global-state - v0.8.3

Published by birdofpreyru over 2 years ago

  • Hotfix of v0.8.3 release.
react-global-state - v0.8.2

Published by birdofpreyru over 2 years ago

  • Adds default export to package.json, pointing to the Node build of the library.
  • Updates dev dependencies.
react-global-state - v0.8.1

Published by birdofpreyru over 2 years ago

  • Patch for useAsyncData() hook: it ensures when the async loading starts during SSR, that the loading value is reported as true in the initial render pass. Without it React 18+ reported UI hydration errors if the async operation timed out during SSR and incomplete render was served to complete the operation on the client-side.