<?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: Hocoh</title>
    <description>The latest articles on DEV Community by Hocoh (@hocoh).</description>
    <link>https://dev.to/hocoh</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%2F138449%2Fd62082d0-ed29-4670-97bd-c07cfb16b4ec.png</url>
      <title>DEV Community: Hocoh</title>
      <link>https://dev.to/hocoh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hocoh"/>
    <language>en</language>
    <item>
      <title>Strange lag in my React Component - state seems to accumulate old state -sandbox provided.</title>
      <dc:creator>Hocoh</dc:creator>
      <pubDate>Wed, 20 Feb 2019 09:59:22 +0000</pubDate>
      <link>https://dev.to/hocoh/strange-lag-in-my-react-component---state-seems-to-accumulate-old-state--sandbox-provided-1ip2</link>
      <guid>https://dev.to/hocoh/strange-lag-in-my-react-component---state-seems-to-accumulate-old-state--sandbox-provided-1ip2</guid>
      <description>&lt;p&gt;&lt;em&gt;I have put a console.log in the render() function to help visualize the state.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here my sandbox:&lt;/strong&gt; &lt;a href="https://codesandbox.io/s/77ymmnpr1"&gt;https://codesandbox.io/s/77ymmnpr1&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What I'm doing:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In my code I'm creating three labels that are expandable, then I put some labelComponent to overlaying them. The overlay got a button to come back on the menu. The problem is that when I then expand an another labelComponent, there is a slight lag with the old state then the new state displayed. Hence the console.log I'm providing to you.&lt;/p&gt;

&lt;p&gt;That put something like following in the console:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;PATHNAME: newState

PATHNAME: oldState

PATHNAME: newState

PATHNAME: oldState
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;edit:&lt;/strong&gt; other possible weird behavior is my component to display the old state on an incremental lagging. Seems then that the state accumulate old state then display it in a kind of messed order, or kind of thing like that.&lt;/p&gt;

&lt;p&gt;In which case my console returns on second rendering:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;stateOne

current state
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;then, on third rendering:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;stateOne

stateTwo

currentState
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;on fourth rendering:&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;stateOne

stateTwo

stateThree

currentState
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

&lt;p&gt;etc. the firsts state are the olds state then come the currentState&lt;/p&gt;

&lt;p&gt;What that mean? I call this.setState() only to put in it the new state, so why it come back to the old state?&lt;/p&gt;

&lt;p&gt;Any hint would be great,&lt;/p&gt;

&lt;p&gt;thanks&lt;/p&gt;

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