react-refresh 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -462,22 +462,37 @@ function _getMountedRootCount() {
462
462
 
463
463
  function createSignatureFunctionForTransform() {
464
464
  {
465
- var call = 0;
465
+ // We'll fill in the signature in two steps.
466
+ // First, we'll know the signature itself. This happens outside the component.
467
+ // Then, we'll know the references to custom Hooks. This happens inside the component.
468
+ // After that, the returned function will be a fast path no-op.
469
+ var status = 'needsSignature';
466
470
  var savedType;
467
471
  var hasCustomHooks;
468
472
  return function (type, key, forceReset, getCustomHooks) {
469
- switch (call++) {
470
- case 0:
471
- savedType = type;
472
- hasCustomHooks = typeof getCustomHooks === 'function';
473
- setSignature(type, key, forceReset, getCustomHooks);
473
+ switch (status) {
474
+ case 'needsSignature':
475
+ if (type !== undefined) {
476
+ // If we received an argument, this is the initial registration call.
477
+ savedType = type;
478
+ hasCustomHooks = typeof getCustomHooks === 'function';
479
+ setSignature(type, key, forceReset, getCustomHooks); // The next call we expect is from inside a function, to fill in the custom Hooks.
480
+
481
+ status = 'needsCustomHooks';
482
+ }
483
+
474
484
  break;
475
485
 
476
- case 1:
486
+ case 'needsCustomHooks':
477
487
  if (hasCustomHooks) {
478
488
  collectCustomHooksForSignature(savedType);
479
489
  }
480
490
 
491
+ status = 'resolved';
492
+ break;
493
+
494
+ case 'resolved':
495
+ // Do nothing. Fast path for all future renders.
481
496
  break;
482
497
  }
483
498
 
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "keywords": [
5
5
  "react"
6
6
  ],
7
- "version": "0.4.2",
7
+ "version": "0.4.3",
8
8
  "homepage": "https://reactjs.org/",
9
9
  "bugs": "https://github.com/facebook/react/issues",
10
10
  "license": "MIT",