Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Commit

Permalink
docs(readme): fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
derrickbeining committed Dec 5, 2018
1 parent f35ff1f commit 9b1bc4b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@

## Description

`react-atom` provides a simple way to manage state in React, for both global app state and for local component state: ✨ `Atom`s ✨
`react-atom` provides a simple way to manage state in React, for both global app state and for local component state:

`Atom`s ✨

### Put your state in an `Atom`:

Expand Down Expand Up @@ -95,8 +97,8 @@ You don't need to do anything special for managing side-effects. Just write your

```js
const saveColor = async color => {
const { userId } = deref(appState);
const theme = await post(`/api/user/${userId}/theme`);
const { userId, color } = deref(appState);
const theme = await post(`/api/user/${userId}/theme`, { color });
swap(appState, state => ({ ...state, color: theme.color }));
};
```
Expand Down Expand Up @@ -165,7 +167,7 @@ function Awkwardddd(props) {
const [bigState, setBigState] = useState({ ...useYourImagination });

const updateName = evt => setName(evt.target.value);
const handleDidComplete = val => setState({ ...bigState, inner: val });
const handleDidComplete = val => setBigState({ ...bigState, inner: val });

return (
<>
Expand Down
9 changes: 5 additions & 4 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ <h4 id="disclaimer-the-react-hooks-api-is-currently-only-a-proposal-therefore-th
<li><a href="#contributing--feedback">Contributing / Feedback</a></li>
</ul>
<h2 id="description">Description</h2>
<p><code>react-atom</code> provides a simple way to manage state in React, for both global app state and for local component state: ✨ <code>Atom</code>s ✨</p>
<p><code>react-atom</code> provides a simple way to manage state in React, for both global app state and for local component state:</p>
<p><code>Atom</code>s ✨</p>
<h3 id="put-your-state-in-an-atom-">Put your state in an <code>Atom</code>:</h3>
<pre><code class="language-ts"><span class="hljs-keyword">import</span> { Atom } <span class="hljs-keyword">from</span> <span class="hljs-string">"@dbeining/react-atom"</span>;

Expand Down Expand Up @@ -128,8 +129,8 @@ <h3 id="update-the-state-with-swap">Update the state with <code>swap</code></h3>
<h3 id="side-effects-just-use-swap-">Side-Effects? Just use <code>swap</code>.</h3>
<p>You don&#39;t need to do anything special for managing side-effects. Just write your IO-related logic as per usual, and call <code>swap</code> when you&#39;ve got what you need. For example:</p>
<pre><code class="language-js"><span class="hljs-keyword">const</span> saveColor = <span class="hljs-keyword">async</span> color =&gt; {
<span class="hljs-keyword">const</span> { userId } = deref(appState);
<span class="hljs-keyword">const</span> theme = <span class="hljs-keyword">await</span> post(<span class="hljs-string">`/api/user/<span class="hljs-subst">${userId}</span>/theme`</span>);
<span class="hljs-keyword">const</span> { userId, color } = deref(appState);
<span class="hljs-keyword">const</span> theme = <span class="hljs-keyword">await</span> post(<span class="hljs-string">`/api/user/<span class="hljs-subst">${userId}</span>/theme`</span>, { color });
swap(appState, state =&gt; ({ ...state, <span class="hljs-attr">color</span>: theme.color }));
};</code></pre>
<h3 id="use-atoms-in-components-with-useatom-">Use Atoms in components with ✨ <code>useAtom</code></h3>
Expand Down Expand Up @@ -187,7 +188,7 @@ <h2 id="why-use-react-atom-">Why use <code>react-atom</code>?</h2>
<span class="hljs-keyword">const</span> [bigState, setBigState] = useState({ ...useYourImagination });

<span class="hljs-keyword">const</span> updateName = <span class="hljs-function"><span class="hljs-params">evt</span> =&gt;</span> setName(evt.target.value);
<span class="hljs-keyword">const</span> handleDidComplete = <span class="hljs-function"><span class="hljs-params">val</span> =&gt;</span> setState({ ...bigState, <span class="hljs-attr">inner</span>: val });
<span class="hljs-keyword">const</span> handleDidComplete = <span class="hljs-function"><span class="hljs-params">val</span> =&gt;</span> setBigState({ ...bigState, <span class="hljs-attr">inner</span>: val });

<span class="hljs-keyword">return</span> (
&lt;&gt;
Expand Down

0 comments on commit 9b1bc4b

Please sign in to comment.