<?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: Ai</title>
    <description>The latest articles on DEV Community by Ai (@uwu).</description>
    <link>https://dev.to/uwu</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%2F685746%2F8de5d264-5f85-496a-aaff-2d985c59c02d.png</url>
      <title>DEV Community: Ai</title>
      <link>https://dev.to/uwu</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/uwu"/>
    <language>en</language>
    <item>
      <title>Lumping together React hooks</title>
      <dc:creator>Ai</dc:creator>
      <pubDate>Thu, 21 Oct 2021 08:17:04 +0000</pubDate>
      <link>https://dev.to/uwu/lumping-together-react-hooks-3akn</link>
      <guid>https://dev.to/uwu/lumping-together-react-hooks-3akn</guid>
      <description>&lt;p&gt;This week at &lt;a href="https://www.techtalentsouth.com/"&gt;TTS&lt;/a&gt;, my class is learning about React hooks. One assignemnt involved watching PedroTech's &lt;a href="https://www.youtube.com/watch?v=LlvBzyy-558"&gt;react hooks course&lt;/a&gt; video and writing about three hooks.&lt;/p&gt;

&lt;p&gt;This article is a "wrapper" around that assignment. I'll actually discuss all 10 prebuilt hooks albeit at a shallow level. Please let me know if I got anything wrong.&lt;/p&gt;




&lt;h2&gt;
  
  
  &lt;code&gt;useState()&lt;/code&gt;, &lt;code&gt;useMemo()&lt;/code&gt;, and &lt;code&gt;useReducer()&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Track state and signal DOM renders.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://reactjs.org/docs/hooks-reference.html#usestate"&gt;📝 useState()&lt;/a&gt; signals a render whenever its state changes. Use this be default.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://reactjs.org/docs/hooks-reference.html#usememo"&gt;📝 useMemo()&lt;/a&gt; signals a render based on other state dependencies you pass it. Use this when you want to &lt;a href="https://en.wikipedia.org/wiki/Memoization"&gt;memoize&lt;/a&gt; expensive calculations.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://reactjs.org/docs/hooks-reference.html#usecallback"&gt;📝 useCallback()&lt;/a&gt; signals a render based on component-level dependencies. Also use this to &lt;a href="https://en.wikipedia.org/wiki/Memoization"&gt;memoize&lt;/a&gt; expensive calculations.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://reactjs.org/docs/hooks-reference.html#usereducer"&gt;📝 useReducer()&lt;/a&gt; provides an API for arbitrary state-render interactions, e.g. update both state &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt; when state &lt;code&gt;z&lt;/code&gt; changes. Use this for "complicated" state-render interactions and when scaling your app is a primary concern.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;useEffect()&lt;/code&gt; and &lt;code&gt;useLayoutEffect()&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Track depencies and signal "side-effects" that don't necessarily affect the DOM.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://reactjs.org/docs/hooks-reference.html#useref"&gt;📝 useEffect()&lt;/a&gt; activates after virtual DOM updates and DOM renders. Use this by default.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://reactjs.org/docs/hooks-reference.html#uselayouteffect"&gt;📝 useLayoutEffect()&lt;/a&gt; activates after virtual DOM updates but before DOM renders. Use this when you want to "measure" DOM properties before render.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;useContext()&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://reactjs.org/docs/hooks-reference.html#usecontext"&gt;📝 useContext()&lt;/a&gt; provides API for passing props down the component tree.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;useRef()&lt;/code&gt; and &lt;code&gt;useImperativeHandle()&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://reactjs.org/docs/hooks-reference.html#useref"&gt;📝 useRef()&lt;/a&gt; tracks real DOM elements. Use this to focus on input fields.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://reactjs.org/docs/hooks-reference.html#useimperativehandle"&gt;📝 useImperativeHandle()&lt;/a&gt; provides an API for exporting the &lt;code&gt;useRef()&lt;/code&gt; reference to other components. Use this when your input is spread across multiple components.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;useDebugValue()&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://reactjs.org/docs/hooks-reference.html#usedebugvalue"&gt;📝 useDebugValue()&lt;/a&gt; provides an API for labeling custom hooks in the console output. Use this when creating a complicated custom hook.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;React hooks are probably difficult to "learn" in isolation because they likely make more sense in a concrete React app. Moreover, it seems like its more important to learn an efficient and effective workflow using many different hooks to accomplish a particular task rather than just "learning" an individual React hook.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;📑 Evan You's &lt;a href="https://www.youtube.com/watch?v=bOdfo5SmQc8"&gt;talk&lt;/a&gt; at dotJS 2019 provides great context for why we even have hooks in React as well as similar ideas in other libraries/frameworks like Vue and Svelte.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;p&gt;Banner source: &lt;a href="https://www.youtube.com/watch?v=fvFO4eLp7oc&amp;amp;t=79s"&gt;🎥 いしわたり淳治 ＆ 砂原良徳 ＋ やくしまるえつこ「神様のいうとおり」（2010）&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Article source: &lt;a href="https://github.com/Ai-Yukino/dev.to/tree/main/10-21-21-Thursday/1"&gt;🐙🐱 Ai-Yukino/dev.to&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
    </item>
    <item>
      <title>React + Vite quick start</title>
      <dc:creator>Ai</dc:creator>
      <pubDate>Wed, 20 Oct 2021 17:15:23 +0000</pubDate>
      <link>https://dev.to/uwu/react-vite-quick-start-5250</link>
      <guid>https://dev.to/uwu/react-vite-quick-start-5250</guid>
      <description>&lt;p&gt;I convinced my class at &lt;a href="https://www.techtalentsouth.com/"&gt;Tech Talent South&lt;/a&gt; to use Vite instead of &lt;code&gt;create-react-app&lt;/code&gt;. These are some notes I wrote to help my instructor, TA, and classmates start using Vite.&lt;/p&gt;




&lt;h2&gt;
  
  
  Single command quick start (Windows)
&lt;/h2&gt;

&lt;p&gt;(These instructions may work for non-Windows computers, but it didn't work for at least one of my classmates who used Linux. You can always look at the official Vite &lt;a href="https://vitejs.dev/guide/"&gt;documentation&lt;/a&gt; for more details.)&lt;/p&gt;

&lt;p&gt;Run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm init vite@latest my-vue-app -- --template react
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Navigate to your project and install dependencies via&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cd my-vue-app
npm i
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run your app with&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For more info, check out the &lt;a href="https://vitejs.dev/guide/#trying-vite-online"&gt;docs&lt;/a&gt; or Evan You's 14 minute &lt;a href="https://www.youtube.com/watch?v=DkGV5F4XnfQ"&gt;demo video&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Multiple command quick start
&lt;/h2&gt;

&lt;p&gt;Run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm init vite@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and select the options you want.&lt;/p&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://vitejs.dev/guide/#trying-vite-online"&gt;📝 Docs&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.youtube.com/watch?v=DkGV5F4XnfQ"&gt;🎥 Demo video&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://hacks.mozilla.org/2018/03/es-modules-a-cartoon-deep-dive/"&gt;👥 Why ES modules?&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Notes
&lt;/h2&gt;

&lt;h3&gt;
  
  
  👀Replacing &lt;code&gt;create-react-app&lt;/code&gt; with Vite👀
&lt;/h3&gt;

&lt;p&gt;Tips:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;code&gt;.jsx&lt;/code&gt; files instead of &lt;code&gt;.js&lt;/code&gt; files unless you're writing pure JavaScript.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;Banner source: &lt;a href="https://www.youtube.com/watch?v=2b1IexhKPz4&amp;amp;t=79s"&gt;🎥 きゅうくらりん / いよわ feat.可不（Kyu-kurarin / Iyowa feat.Kafu）&lt;/a&gt;&lt;br&gt;&lt;br&gt;
Article source: &lt;a href="https://github.com/Ai-Yukino/dev.to/tree/main/10-20-21-Wednesday-1"&gt;🐙🐱 Ai-Yukino/dev.to&lt;/a&gt;&lt;/p&gt;

</description>
      <category>react</category>
      <category>vite</category>
    </item>
  </channel>
</rss>
