<?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>Forem: Harish Sankaramanchi</title>
    <description>The latest articles on Forem by Harish Sankaramanchi (@ssharish).</description>
    <link>https://forem.com/ssharish</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%2F257765%2F7279a472-3b3d-4d6d-a70c-9cf162341da3.jpg</url>
      <title>Forem: Harish Sankaramanchi</title>
      <link>https://forem.com/ssharish</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ssharish"/>
    <language>en</language>
    <item>
      <title>Run useEffect Only Once :React
</title>
      <dc:creator>Harish Sankaramanchi</dc:creator>
      <pubDate>Thu, 13 Feb 2020 12:15:25 +0000</pubDate>
      <link>https://forem.com/ssharish/run-useeffect-only-once-react-57go</link>
      <guid>https://forem.com/ssharish/run-useeffect-only-once-react-57go</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cmT0gt13--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hfmjb0x6ht3oywqs6cvh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cmT0gt13--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/hfmjb0x6ht3oywqs6cvh.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;br&gt;
If you want to run an effect and clean it up only once (on mount and unmount), you can pass an empty array ([]) as a second argument. This tells React that your effect doesn’t depend on any values from props or state, so it never needs to re-run. This isn’t handled as a special case — it follows directly from how the dependencies array always works.&lt;br&gt;
If you pass an empty array ([]), the props and state inside the effect will always have their initial values. While passing [] as the second argument is closer to the familiar componentDidMount and componentWillUnmount mental model, there are usually better solutions to avoid re-running effects too often. Also, don’t forget that React defers running useEffect until after the browser has painted, so doing extra work is less of a problem.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>reactnative</category>
    </item>
  </channel>
</rss>
