Skip to content

Commit

Permalink
[#82] Docs updates
Browse files Browse the repository at this point in the history
  • Loading branch information
birdofpreyru committed Apr 1, 2024
1 parent f43ec44 commit 566c18a
Show file tree
Hide file tree
Showing 4 changed files with 320 additions and 317 deletions.
15 changes: 4 additions & 11 deletions docs/docs/api/hooks/useglobalstate.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,6 @@ or change objects already written into the global state, without explicitly
clonning them first yourself.
:::

:::caution
State update notifications are asynchronous. When your code does multiple
global state updates in the same React rendering cycle, all state update
notifications are queued and dispatched together, after the current
rendering cycle. In other words, in any given rendering cycle the global
state values are "fixed", and all changes becomes visible at once in the
next triggered rendering pass.
:::

The TypeScript signature of [useGlobalState()] implementation is

```ts
Expand Down Expand Up @@ -136,15 +127,17 @@ It returns an array with two elements `[value, setValue]` (see the type
to update the value at `path`.

Similar to the standard React's `useState()`, it supports
[functional value updates](https://reactjs.org/docs/hooks-reference.html#functional-updates):
[functional value updates][functional updates]:
if `setValue()` is called with a function as argument, that function will
be called and its return value will be written to `path`. Otherwise,
be called with the current state value as its argument, and its return value
will be written to `path`. Otherwise,
the argument of `setValue()` itself is written to `path`.

Also, similar to the standard React's state setters, `setValue()` is
a stable function: it does not change between component re-renders.

[ForceT]: /docs/api/types/force
[functional updates]: https://reactjs.org/docs/hooks-reference.html#functional-updates
[GlobalState]: /docs/api/classes/globalstate
[SetterT]: /docs/api/types/setter
[useGlobalState()]: #
Expand Down
1 change: 1 addition & 0 deletions docs/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const config = {
tagline: 'React global state designed right',
url: 'https://dr.pogodin.studio',
baseUrl: '/docs/react-global-state/',
onBrokenAnchors: 'throw',
onBrokenLinks: 'throw',
onBrokenMarkdownLinks: 'throw',
favicon: 'img/favicon.ico',
Expand Down

0 comments on commit 566c18a

Please sign in to comment.