<p dir="auto"><strong>Do you want to request a <em>feature</em> or report a <em>bug</em>?</strong></p>
<p dir="auto">feature</p>
<p dir="auto"><strong>What is the current behavior?</strong></p>
<p dir="auto"><code class="notranslate">getDerivedStateFromProps</code> only receives the nextProps and previousState as arguments.</p>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. Your bug will get fixed much faster if we can run your code and it doesn't have dependencies other than React. Paste the link to your JSFiddle (<a href="https://jsfiddle.net/Luktwrdm/" rel="nofollow">https://jsfiddle.net/Luktwrdm/</a>) or CodeSandbox (<a href="https://codesandbox.io/s/new" rel="nofollow">https://codesandbox.io/s/new</a>) example below:</strong></p>
<p dir="auto">The deprecated <code class="notranslate">componentWillReceiveProps(nextProps)</code> used to allow code like <code class="notranslate">this.props.foo !== nextProps.foo</code>. With the new <code class="notranslate">getDerivedStateFromProps</code> function, there's no choice (because it is a static method) but to constantly copy <code class="notranslate">nextProps.foo</code> into state in order to access it later.</p>
<p dir="auto">This is illustrated in the example posted to twitter by <a class="user-mention notranslate" data-hovercard-type="user" data-hovercard-url="/users/gaearon/hovercard" data-octo-click="hovercard-link-click" data-octo-dimensions="link_type:self" href="https://github.com/gaearon">@gaearon</a>: <a href="https://twitter.com/dan_abramov/status/953612246634188800?lang=en" rel="nofollow">https://twitter.com/dan_abramov/status/953612246634188800?lang=en</a></p>
<p dir="auto"><strong>What is the expected behavior?</strong></p>
<p dir="auto">Ideally (if it's not difficult to implement!) the <code class="notranslate">getDerivedStateFromProps</code> would also take the current (previous/old) props as an argument, something like:</p>
<p dir="auto"><code class="notranslate">getDerivedStateFromProps(nextProps, prevState, prevProps)</code></p>
<p dir="auto">This would eliminate the need to constantly assign props to state purely for comparison purposes...</p>
<p dir="auto">A quick look at the source doesn't make it clear to me how easy this would be though...</p>
<p dir="auto"></p><div class="Box Box--condensed my-2">
  <div class="Box-header f6">
    <p class="mb-0 text-bold">
      <a href="https://github.com/facebook/react/blob/4a20ff26ecfe9bc66941d79f7fce2c67be8ee236/packages/react-dom/src/server/ReactPartialRenderer.js#L456">react/packages/react-dom/src/server/ReactPartialRenderer.js</a>
    </p>
    <p class="mb-0 color-fg-muted">
         Line 456
      in
      <a data-pjax="true" class="commit-tease-sha" href="/facebook/react/commit/4a20ff26ecfe9bc66941d79f7fce2c67be8ee236">4a20ff2</a>
    </p>
  </div>
  <div itemprop="text" class="Box-body p-0 blob-wrapper blob-wrapper-embedded data">
    <table class="highlight tab-size mb-0 js-file-line-container" data-tab-size="8" data-paste-markdown-skip="">

        <tbody><tr class="border-0">
          <td id="L456" class="blob-num border-0 px-3 py-0 color-bg-default" data-line-number="456"></td>
          <td id="LC456" class="blob-code border-0 px-3 py-0 color-bg-default blob-code-inner js-file-line"> <span class="pl-s1">partialState</span> <span class="pl-c1">=</span> <span class="pl-v">Component</span><span class="pl-kos">.</span><span class="pl-c1">getDerivedStateFromProps</span><span class="pl-kos">.</span><span class="pl-en">call</span><span class="pl-kos">(</span> </td>
        </tr>
    </tbody></table>
  </div>
</div>
<p></p>
<p dir="auto"><strong>Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?</strong></p>
<p dir="auto">16.3.0</p>
<p dir="auto"><strong>Do you want to request a <em>feature</em> or report a <em>bug</em>?</strong><br>
bug</p>
<p dir="auto"><strong>What is the current behavior?</strong><br>
Our tests are sporadically logging a warning <code class="notranslate">Warning: ReactDebugTool: debugID may not be empty.</code>. We fail any tests that log warnings, so this is causing flakiness.</p>
<p dir="auto"><strong>If the current behavior is a bug, please provide the steps to reproduce...</strong><br>
I'm unable to consistently reproduce, but we're seeing roughly a 2% failure rate for our test suite. Doesn't seem to be any patterns around which tests will fail with this error.</p>
<p dir="auto"><strong>What is the expected behavior?</strong><br>
I'd expect our tests to either log a warning consistently if we're doing something wrong or to not log a warning at all.</p>
<p dir="auto"><strong>Which versions of React, and which browser / OS are affected by this issue? Did this work in previous versions of React?</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="❯ node --version; npm --version; npm ls react react-dom enzyme
v6.10.2
2.15.12
Airbnb@1.0.0 /Users/gary_borton/airlab/repos/airbnb
├── enzyme@2.8.0 
├── react@15.4.2 
├── react-dom@15.4.2 
└─┬ react-router-dom@4.1.1
  └── react@15.5.4 "><pre class="notranslate"><code class="notranslate">❯ node --version; npm --version; npm ls react react-dom enzyme
v6.10.2
2.15.12
Airbnb@1.0.0 /Users/gary_borton/airlab/repos/airbnb
├── enzyme@2.8.0 
├── react@15.4.2 
├── react-dom@15.4.2 
└─┬ react-router-dom@4.1.1
  └── react@15.5.4 
</code></pre></div>
<p dir="auto">The appearance of this warning correlates pretty closely with our migration from node 4 to node 6.</p>