<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>React on dev notes</title>
    <link>https://juhanakristianblog.netlify.app/tags/react/</link>
    <description>Recent content in React on dev notes</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <lastBuildDate>Sun, 13 Mar 2022 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://juhanakristianblog.netlify.app/tags/react/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>How to implement useMediaQuery hook in React</title>
      <link>https://juhanakristianblog.netlify.app/posts/how-to-implement-usemediaquery-hook-in-react/</link>
      <pubDate>Sun, 13 Mar 2022 00:00:00 +0000</pubDate>
      <guid>https://juhanakristianblog.netlify.app/posts/how-to-implement-usemediaquery-hook-in-react/</guid>
      <description>&lt;h3 id=&#34;what-are-media-queries&#34;&gt;What are Media Queries?&lt;/h3&gt;&#xA;&lt;p&gt;&lt;a href=&#34;https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries&#34;&gt;Media Queries&lt;/a&gt; are a CSS feature that can be used to conditionally apply selected styles on an HTML element. Some examples of media queries include checking for the width of the browser window, checking for the media type (print, screen), or checking for dark/light mode preference.&lt;/p&gt;&#xA;&lt;p&gt;The most common use case for media queries is using it to implement responsivity on a website. Checking for the width of the viewport and applying styles based on it allows us to define different styles on different devices (desktop, mobile, tablet).&lt;/p&gt;</description>
    </item>
    <item>
      <title>Basics of React server-side rendering with Express.js</title>
      <link>https://juhanakristianblog.netlify.app/posts/basics-of-react-server-side-rendering-with-express-js/</link>
      <pubDate>Sat, 05 Feb 2022 00:00:00 +0000</pubDate>
      <guid>https://juhanakristianblog.netlify.app/posts/basics-of-react-server-side-rendering-with-express-js/</guid>
      <description>&lt;p&gt;If you want to develop SEO friendly and fast websites with React, you have two choices: server-side rendering (SSR) or static site generation (SSG).&lt;/p&gt;&#xA;&lt;p&gt;There are some awesome frameworks like &lt;a href=&#34;https://remix.run/&#34;&gt;remix.run&lt;/a&gt; , &lt;a href=&#34;https://nextjs.org/&#34;&gt;next.js&lt;/a&gt;, &lt;a href=&#34;https://astro.build/&#34;&gt;astro&lt;/a&gt; or &lt;a href=&#34;https://www.11ty.dev/&#34;&gt;11ty&lt;/a&gt;, which allow you to use one of (or both) techniques. So if you&amp;rsquo;re building a production app, I recommend using one of them because server-side rendering is quite hard to get right.&lt;/p&gt;&#xA;&lt;p&gt;&lt;strong&gt;But&lt;/strong&gt; if you want to understand how it works and what is happening under the hood in these frameworks, you definately should try it out. This article will focus on how SSR works and we will also go through a simple example of using SSR.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Should you use React.FC to type your components?</title>
      <link>https://juhanakristianblog.netlify.app/posts/should-you-use-reactfc-to-type-your-components/</link>
      <pubDate>Tue, 07 Dec 2021 00:00:00 +0000</pubDate>
      <guid>https://juhanakristianblog.netlify.app/posts/should-you-use-reactfc-to-type-your-components/</guid>
      <description>&lt;p&gt;&lt;strong&gt;TLDR:&lt;/strong&gt; &lt;a href=&#34;https://github.com/facebook/create-react-app/pull/8177&#34;&gt;No&lt;/a&gt;. &lt;a href=&#34;https://github.com/typescript-cheatsheets/react#function-components&#34;&gt;You&lt;/a&gt; &lt;a href=&#34;https://kentcdodds.com/blog/how-to-write-a-react-component-in-typescript&#34;&gt;should&lt;/a&gt; probably &lt;a href=&#34;https://twitter.com/nickemccurdy/status/1365384372908621833&#34;&gt;not&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-ts&#34; data-lang=&#34;ts&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Dialog&lt;/span&gt;: &lt;span style=&#34;color:#66d9ef&#34;&gt;React.FC&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; ({&lt;span style=&#34;color:#a6e22e&#34;&gt;children&lt;/span&gt;}) &lt;span style=&#34;color:#f92672&#34;&gt;=&amp;gt;&lt;/span&gt; {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#x9;&lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; (&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#x9;&#x9;...&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#x9;)&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The consensus in the React community now seems to be that, you should avoid using &lt;code&gt;React.FC&lt;/code&gt; because it causes the component to implicitly take &lt;code&gt;children&lt;/code&gt;. This means the component will accept children, even if they&amp;rsquo;re not supposed to.&lt;/p&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s take a look at the pros and cons of &lt;code&gt;React.FC&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;h2 id=&#34;pros-of-reactfc&#34;&gt;Pros of React.FC&lt;/h2&gt;&#xA;&lt;h3 id=&#34;excplicit-return-type&#34;&gt;Excplicit return type&lt;/h3&gt;&#xA;&lt;p&gt;In addition to the &lt;code&gt;children&lt;/code&gt; prop, &lt;code&gt;React.FC&lt;/code&gt; declares an explicit return type for the component. The return type is &lt;code&gt;ReactElement | null;&lt;/code&gt; and we will get a type error if we try to return something else from the component.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Use useReducer to manage complex state</title>
      <link>https://juhanakristianblog.netlify.app/posts/use-userreducer-to-manage-complex-state/</link>
      <pubDate>Sat, 31 Oct 2020 00:00:00 +0000</pubDate>
      <guid>https://juhanakristianblog.netlify.app/posts/use-userreducer-to-manage-complex-state/</guid>
      <description>&lt;p&gt;&lt;code&gt;useReducer&lt;/code&gt; is a React Hook which helps you manage complex state with a simple API. The hook takes a reducer function and the initial state as parameters. You can also pass in an optional argument which can be a function for lazy initialization of the state.&lt;/p&gt;&#xA;&lt;p&gt;Here&amp;rsquo;s the simplest example of using useReducer you can think of.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-js&#34; data-lang=&#34;js&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;React&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;react&amp;#34;&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;reducer&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;value&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;newValue&lt;/span&gt;) {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;newValue&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;export&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;default&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;App&lt;/span&gt;() {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; [&lt;span style=&#34;color:#a6e22e&#34;&gt;value&lt;/span&gt;, &lt;span style=&#34;color:#a6e22e&#34;&gt;setValue&lt;/span&gt;] &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;React&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;useReducer&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;reducer&lt;/span&gt;, &lt;span style=&#34;color:#ae81ff&#34;&gt;0&lt;/span&gt;);&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; (&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;div&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;className&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;App&amp;#34;&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;h1&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;value&lt;/span&gt;}&lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;/h1&amp;gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;button&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;onClick&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{() =&amp;gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;setValue&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;value&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;+&lt;/span&gt; &lt;span style=&#34;color:#ae81ff&#34;&gt;1&lt;/span&gt;)}&lt;span style=&#34;color:#f92672&#34;&gt;&amp;gt;&lt;/span&gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;Increment&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;/button&amp;gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &lt;span style=&#34;color:#f92672&#34;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;/div&amp;gt;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  );&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We are using &lt;code&gt;useReducer&lt;/code&gt; for managing a single value, like when we use &lt;code&gt;useState&lt;/code&gt;. But &lt;code&gt;useReducer&lt;/code&gt; can do much more than that!&lt;/p&gt;</description>
    </item>
    <item>
      <title>Manage React state with the useContext hook</title>
      <link>https://juhanakristianblog.netlify.app/posts/manage-react-state-with-the-usecontext-hook/</link>
      <pubDate>Wed, 14 Oct 2020 00:00:00 +0000</pubDate>
      <guid>https://juhanakristianblog.netlify.app/posts/manage-react-state-with-the-usecontext-hook/</guid>
      <description>&lt;p&gt;&lt;strong&gt;DISCLAIMER&lt;/strong&gt;: This post is based on state management ideas presented by Kent C. Dodd’s in &lt;a href=&#34;https://kentcdodds.com/blog/application-state-management-with-react&#34;&gt;Application state management with React&lt;/a&gt;. If you haven&amp;rsquo;t read it, I encourage you to do so.&lt;/p&gt;&#xA;&lt;p&gt;React projects have many options for managing state. While libraries like &lt;code&gt;redux&lt;/code&gt; and &lt;code&gt;mobx&lt;/code&gt; are a popular choice, React also has it&amp;rsquo;s own API for managing state. The Context API is useful when you have state which is accessed in multiple places in your app and you want to avoid &lt;a href=&#34;https://kentcdodds.com/blog/prop-drilling&#34;&gt;prop drilling&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Make custom marker displaying users location and direction with react-native-maps on iOS</title>
      <link>https://juhanakristianblog.netlify.app/posts/make-custom-marker-displaying-users-location-and-direction/</link>
      <pubDate>Wed, 30 Sep 2020 00:00:00 +0000</pubDate>
      <guid>https://juhanakristianblog.netlify.app/posts/make-custom-marker-displaying-users-location-and-direction/</guid>
      <description>&lt;p&gt;&lt;strong&gt;NOTICE:&lt;/strong&gt; This post is about showing a custom location and direction indicator with react-native-maps on &lt;strong&gt;iOS&lt;/strong&gt;. This involves a &lt;em&gt;hack&lt;/em&gt; which probably isn&amp;rsquo;t needed on Android. On Android rotation works just by adding the &lt;code&gt;rotation&lt;/code&gt;prop to the Marker and setting it to the current heading. As far as I know this hack is only required for iOS.&lt;/p&gt;&#xA;&lt;p&gt;If you want to display the current GPS location with your own custom graphics in React Native Maps, you need to create a custom Marker. This is done fairly easily, since the Marker component accepts a View as child.&lt;/p&gt;</description>
    </item>
    <item>
      <title>What is React Strict Mode?</title>
      <link>https://juhanakristianblog.netlify.app/posts/what-is-react-strict-mode/</link>
      <pubDate>Sat, 26 Sep 2020 00:00:00 +0000</pubDate>
      <guid>https://juhanakristianblog.netlify.app/posts/what-is-react-strict-mode/</guid>
      <description>&lt;p&gt;React Strict Mode is a tool, which comes with React, for detecting possible issues and problems in your application. Currently (Sept. 2020) Strict Mode detects if you have &lt;a href=&#34;https://reactjs.org/docs/strict-mode.html#identifying-unsafe-lifecycles&#34;&gt;unsafe lifecycle methods&lt;/a&gt;, &lt;a href=&#34;https://reactjs.org/docs/strict-mode.html#warning-about-legacy-string-ref-api-usage&#34;&gt;usage of legacy string ref API&lt;/a&gt;, &lt;a href=&#34;https://reactjs.org/docs/strict-mode.html#warning-about-deprecated-finddomnode-usage&#34;&gt;usage of findDOMNode&lt;/a&gt;, &lt;a href=&#34;https://reactjs.org/docs/strict-mode.html#detecting-unexpected-side-effects&#34;&gt;detecting unexpected side effects&lt;/a&gt; or &lt;a href=&#34;https://reactjs.org/docs/strict-mode.html#detecting-legacy-context-api&#34;&gt;detecting usage of legacy context API&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;So basically, using Strict Mode will help you detect if your app or libraries are using React APIs which are deprecated, unsafe in async code or have problems which might cause bugs. &lt;strong&gt;Strict Mode warnings are only displayed in development&lt;/strong&gt;, so you don&amp;rsquo;t have to worry about them showing up in production. In the future, Strict Mode will likely add other warnings so even if you don&amp;rsquo;t have any now, it&amp;rsquo;s a good idea to keep using it.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Access DOM element in a child component in React</title>
      <link>https://juhanakristianblog.netlify.app/posts/access-dom-element-in-a-child-component-in-react/</link>
      <pubDate>Tue, 18 Aug 2020 06:45:01 +0000</pubDate>
      <guid>https://juhanakristianblog.netlify.app/posts/access-dom-element-in-a-child-component-in-react/</guid>
      <description>&lt;p&gt;Sometimes we need access a DOM element which is contained by another React component. If we try to just use &lt;a href=&#34;https://reactjs.org/docs/refs-and-the-dom.html&#34;&gt;ref&lt;/a&gt; and pass it to the child component, we get an error.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-jsx&#34; data-lang=&#34;jsx&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;ChildComponent&lt;/span&gt;(&lt;span style=&#34;color:#a6e22e&#34;&gt;props&lt;/span&gt;) {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;ref&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;props&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;ref&lt;/span&gt;}&amp;gt;&lt;span style=&#34;color:#a6e22e&#34;&gt;Hello&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;there&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;!&lt;/span&gt;&amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt;&amp;gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;export&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;default&lt;/span&gt; &lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;App&lt;/span&gt;() {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;const&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;childRef&lt;/span&gt; &lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;React&lt;/span&gt;.&lt;span style=&#34;color:#a6e22e&#34;&gt;useRef&lt;/span&gt;();&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; (&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;className&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;&lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;App&amp;#34;&lt;/span&gt;&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;ChildComponent&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;ref&lt;/span&gt;&lt;span style=&#34;color:#f92672&#34;&gt;=&lt;/span&gt;{&lt;span style=&#34;color:#a6e22e&#34;&gt;childRef&lt;/span&gt;} /&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;div&lt;/span&gt;&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  );&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;&lt;img src=&#34;https://juhanakristianblog.netlify.app/images/referror.png&#34; alt=&#34;&#34;&gt;&lt;/p&gt;&#xA;&lt;p&gt;This is because ref is a reserved prop name so you can&amp;rsquo;t pass it to a child component. Instead we can use forwardRef when defining the child component.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Create a React Hook to show browser online status</title>
      <link>https://juhanakristianblog.netlify.app/posts/create-a-react-hook-to-show-browsers-online-status/</link>
      <pubDate>Sun, 31 May 2020 09:33:01 +0000</pubDate>
      <guid>https://juhanakristianblog.netlify.app/posts/create-a-react-hook-to-show-browsers-online-status/</guid>
      <description>&lt;p&gt;React Hooks are a way of adding logic to your functional components in an simple and elegant way. In addition to the &lt;a href=&#34;https://reactjs.org/docs/hooks-reference.html&#34;&gt;standard hooks&lt;/a&gt; like &lt;code&gt;useState&lt;/code&gt; or &lt;code&gt;useEffect&lt;/code&gt; you can also create your own hooks if find you need the same logic in multiple components.&lt;/p&gt;&#xA;&lt;p&gt;A &lt;a href=&#34;https://reactjs.org/docs/hooks-custom.html&#34;&gt;custom hook&lt;/a&gt; is nothing more than a JavaScript function which starts with &amp;ldquo;use&amp;rdquo; and that may call other hooks. In this article I will show you how to create a simple hook for showing the network status of the users browser.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Making API calls in React useEffect</title>
      <link>https://juhanakristianblog.netlify.app/posts/making-api-calls-with-react-useeffect/</link>
      <pubDate>Sat, 16 May 2020 09:33:01 +0000</pubDate>
      <guid>https://juhanakristianblog.netlify.app/posts/making-api-calls-with-react-useeffect/</guid>
      <description>&lt;p&gt;&lt;code&gt;useEffect&lt;/code&gt; is a &lt;a href=&#34;https://reactjs.org/docs/hooks-effect.html&#34;&gt;hook&lt;/a&gt; added in React 16.8. It allows you to perform &lt;a href=&#34;https://en.wikipedia.org/wiki/Side_effect_(computer_science)&#34;&gt;side effects&lt;/a&gt; in function components. This means you can update things outside of React based on your &lt;code&gt;props&lt;/code&gt;and &lt;code&gt;state&lt;/code&gt;. Fetching data when the component state changes, changing the page &lt;code&gt;&amp;lt;title&amp;gt;&lt;/code&gt; or connecting to a WebSocket server are all examples of side effects that can be done with &lt;code&gt;useEffect&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;As an example, we are going to build a component which fetches data from &lt;a href=&#34;https://alexwohlbruck.github.io/cat-facts/&#34;&gt;Cat Facts API&lt;/a&gt; and displays the received facts as a list. Finally we&amp;rsquo;ll add buttons to select the animal we want facts about.&lt;/p&gt;</description>
    </item>
    <item>
      <title>The very basics of React Hooks</title>
      <link>https://juhanakristianblog.netlify.app/posts/react-hooks-basics/</link>
      <pubDate>Mon, 27 Apr 2020 09:33:01 +0000</pubDate>
      <guid>https://juhanakristianblog.netlify.app/posts/react-hooks-basics/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;https://reactjs.org/docs/hooks-intro.html&#34;&gt;Hooks&lt;/a&gt; are an React API that were introduced in &lt;a href=&#34;https://reactjs.org/blog/2019/02/06/react-v16.8.0.html&#34;&gt;React 16.8&lt;/a&gt; a little more than a year ago (february 2019).&#xA;They let you use &lt;a href=&#34;https://reactjs.org/docs/state-and-lifecycle.html&#34;&gt;state&lt;/a&gt; in your React &lt;a href=&#34;https://reactjs.org/docs/components-and-props.html&#34;&gt;components&lt;/a&gt; without writing classes.&lt;/p&gt;&#xA;&lt;p&gt;In this post I&amp;rsquo;ll talk about the &lt;code&gt;useState&lt;/code&gt; hook and after reading it you&amp;rsquo;ll have a basic idea how to use it to add state to your functional components.&lt;/p&gt;&#xA;&lt;p&gt;Let&amp;rsquo;s start with a simple functional component.&lt;/p&gt;&#xA;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; style=&#34;color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;&#34;&gt;&lt;code class=&#34;language-jsx&#34; data-lang=&#34;jsx&#34;&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;import&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;React&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;from&lt;/span&gt; &lt;span style=&#34;color:#e6db74&#34;&gt;&amp;#34;react&amp;#34;&lt;/span&gt;;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;&lt;span style=&#34;color:#66d9ef&#34;&gt;function&lt;/span&gt; &lt;span style=&#34;color:#a6e22e&#34;&gt;Cat&lt;/span&gt;() {&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  &lt;span style=&#34;color:#66d9ef&#34;&gt;return&lt;/span&gt; (&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &amp;lt;&lt;span style=&#34;color:#f92672&#34;&gt;span&lt;/span&gt;&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;      &lt;span style=&#34;color:#960050;background-color:#1e0010&#34;&gt;🐱&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;    &amp;lt;/&lt;span style=&#34;color:#f92672&#34;&gt;span&lt;/span&gt;&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;  );&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span style=&#34;display:flex;&#34;&gt;&lt;span&gt;}&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Here we are simply rendering a cat emoji inside a humble span element.&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
