<?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: Surya Kiran</title>
    <description>The latest articles on Forem by Surya Kiran (@suryaki28658640).</description>
    <link>https://forem.com/suryaki28658640</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%2F220937%2Fcb1a74c0-d7f9-4d13-a7be-9568bf9fe63e.png</url>
      <title>Forem: Surya Kiran</title>
      <link>https://forem.com/suryaki28658640</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/suryaki28658640"/>
    <language>en</language>
    <item>
      <title>MEASURING COMPONENT PERFORMANCE USING REACT PROFILER API</title>
      <dc:creator>Surya Kiran</dc:creator>
      <pubDate>Fri, 30 Aug 2019 09:50:55 +0000</pubDate>
      <link>https://forem.com/suryaki28658640/measuring-component-performance-using-react-profiler-api-54h</link>
      <guid>https://forem.com/suryaki28658640/measuring-component-performance-using-react-profiler-api-54h</guid>
      <description>&lt;p&gt;Good performance in React application is easy to achieve and also easy to miss, but missed performance loopholes can be more expensive than we can imagine. React provides some exceptional tools to measure performance, and anything measurable can be better monitored and controlled.&lt;/p&gt;

&lt;p&gt;The React profiler is available as part of React devtools in Google chrome extensions, which provides an excellent way to measure and record the performance of the application. At every component level, it ensures the awareness of the performance aspect in the ongoing application development. The new profiler provides a consolidated view of the application components rendered with relative ranking details, grouped by commits in the form of different charts – Flame chart, Ranked chart and specific component charts.&lt;/p&gt;

&lt;p&gt;The latest React 16.9 is out, in which the new features and notable bug fixes make developers job easy.&lt;/p&gt;

&lt;p&gt;With this new version of React, comes the React Profiler API which is now available to measure component performance directly. It is the API which is also internally used by the devtools profiler. It provides a new way to measure the performance at each of the individual component levels by tracking it programmatically.&lt;/p&gt;

&lt;p&gt;With the new release, it is easier to measure and control performance at each component level:&lt;/p&gt;

&lt;p&gt;The frequency of render&lt;br&gt;
The time for each render&lt;br&gt;
The base time for the initial mount or worst-case render time&lt;/p&gt;

&lt;p&gt;The profiler API is particularly helpful in larger applications to get the performance view and impact of regression on a specific component.&lt;/p&gt;

&lt;p&gt;HOW TO USE THE REACT PROFILER API?&lt;/p&gt;

&lt;p&gt;The new Profiler API can be included as an additional tag around each of the components to measure its performance, by giving it a unique id and including a common handler for render.&lt;/p&gt;

&lt;p&gt;const MyGrid = (props) =&amp;gt; {&lt;br&gt;
return (&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
);&lt;br&gt;
};&lt;/p&gt;

&lt;p&gt;Use Profiler tag around any number of components to measure their performance, assign a unique id value to facilitate the identification and thus help to track each component uniquely in the Profiler tree.&lt;br&gt;
Define a generic handler, which is called each time the component is rendered, for the first mount and each subsequent update. This can be defined as a common utility function with the profiling data handling logic and can be used across the application whenever profiling any component.&lt;/p&gt;

&lt;p&gt;The handler receives the profiling details which can be used appropriately to measure and track the performance parameters of the component.&lt;/p&gt;

&lt;p&gt;function onRenderCallback(&lt;br&gt;
id, &lt;br&gt;
phase, &lt;br&gt;
actualDuration, &lt;br&gt;
baseDuration, &lt;br&gt;
startTime, &lt;br&gt;
commitTime, &lt;br&gt;
interactions &lt;br&gt;
) {&lt;br&gt;
//Logic to handle the profiling details&lt;br&gt;
console.log( 'The component', id, ', The phase', phase,', Time taken for the update',  actualDuration, baseDuration, startTime, commitTime, interactions);&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Source:&lt;a href="https://walkingtree.tech/measuring-component-performance-using-react-profiler-api/"&gt;https://walkingtree.tech/measuring-component-performance-using-react-profiler-api/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>reactprofilerapi</category>
      <category>react</category>
      <category>api</category>
      <category>devtoolswebdev</category>
    </item>
  </channel>
</rss>
