<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dr. Sergey Pogodin</title>
    <description>The latest articles on DEV Community by Dr. Sergey Pogodin (@birdofpreyru).</description>
    <link>https://dev.to/birdofpreyru</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F491069%2F2c28b26b-0806-4ef0-9ec4-bcc2e98ef7a2.jpeg</url>
      <title>DEV Community: Dr. Sergey Pogodin</title>
      <link>https://dev.to/birdofpreyru</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/birdofpreyru"/>
    <language>en</language>
    <item>
      <title>Global State in React</title>
      <dc:creator>Dr. Sergey Pogodin</dc:creator>
      <pubDate>Thu, 15 Oct 2020 21:22:00 +0000</pubDate>
      <link>https://dev.to/birdofpreyru/global-state-in-react-2ca4</link>
      <guid>https://dev.to/birdofpreyru/global-state-in-react-2ca4</guid>
      <description>&lt;p&gt;A year ago I engineered my own React library for the global state and asynchronous data management with Context API and hooks (yeah, yet another take on such library :) It worked great for me ever since, but nobody else knows it. Recently I got an inspiration to write a little article / tutorial about it, and share it with the world, to see if anybody else likes it, and probably to receive some feedback. Check it out:&lt;/p&gt;

&lt;p&gt;NPM: &lt;a href="https://www.npmjs.com/package/@dr.pogodin/react-global-state"&gt;https://www.npmjs.com/package/@dr.pogodin/react-global-state&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Article: &lt;a href="https://dr.pogodin.studio/dev-blog/the-global-state-in-react-designed-right"&gt;https://dr.pogodin.studio/dev-blog/the-global-state-in-react-designed-right&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;P.S.:&lt;/strong&gt; Why this one is better than a myrriad of alternatives? It allows to load some remote data into some.path of global state with a simple hook&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const { data, loading, timestamp } = useAsyncData('some.path', asyncLoaderFunction)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and takes care to provide a way for it to work in Server-Side Rendering (SSR), and within split code chunks. And the simple synchronous usage of global state works with a hook closely mimicing the standard local state:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const [value, setValue] = useGlobalState('some.path.in.state', 'Optional initial value (can also be a number, an object, on an array)')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So far I have not seen all the same functionality in any alternative lib.&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
