See the issue and the test case with original fix in https://github.com/facebook/react/pull/14802.

We'll need to fix it properly, see https://github.com/facebook/react/pull/14802#issuecomment-463277621.
'%s received a final argument during this render, but not during ' +
        'the previous render. Even though the final argument is optional, ' +
        'its type cannot change between renders.',
      currentHookNameInDev,
    );
    return false;
  }
  
  
  if (nextDeps.length !== prevDeps.length) {
    warning(
      false,
      'The final argument passed to %s changed size between renders. The ' +
        'order and size of this array must remain constant.\n\n' +
        'Previous: %s\n' +
        'Incoming: %s',
      currentHookNameInDev,
      `[${nextDeps.join(', ')}]`,
      `[${prevDeps.join(', ')}]`,
    );
  }
  for (let i = 0; i < prevDeps.length && i < nextDeps.length; i++) {
    if (is(nextDeps[i], prevDeps[i])) {
      continue;
    }
    return false;
  }
  return true;
}
class Updater {