react-refresh 0.7.1 → 0.7.2

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.
@@ -535,22 +535,37 @@ function _getMountedRootCount() {
535
535
 
536
536
  function createSignatureFunctionForTransform() {
537
537
  {
538
- var call = 0;
538
+ // We'll fill in the signature in two steps.
539
+ // First, we'll know the signature itself. This happens outside the component.
540
+ // Then, we'll know the references to custom Hooks. This happens inside the component.
541
+ // After that, the returned function will be a fast path no-op.
542
+ var status = 'needsSignature';
539
543
  var savedType;
540
544
  var hasCustomHooks;
541
545
  return function (type, key, forceReset, getCustomHooks) {
542
- switch (call++) {
543
- case 0:
544
- savedType = type;
545
- hasCustomHooks = typeof getCustomHooks === 'function';
546
- setSignature(type, key, forceReset, getCustomHooks);
546
+ switch (status) {
547
+ case 'needsSignature':
548
+ if (type !== undefined) {
549
+ // If we received an argument, this is the initial registration call.
550
+ savedType = type;
551
+ hasCustomHooks = typeof getCustomHooks === 'function';
552
+ setSignature(type, key, forceReset, getCustomHooks); // The next call we expect is from inside a function, to fill in the custom Hooks.
553
+
554
+ status = 'needsCustomHooks';
555
+ }
556
+
547
557
  break;
548
558
 
549
- case 1:
559
+ case 'needsCustomHooks':
550
560
  if (hasCustomHooks) {
551
561
  collectCustomHooksForSignature(savedType);
552
562
  }
553
563
 
564
+ status = 'resolved';
565
+ break;
566
+
567
+ case 'resolved':
568
+ // Do nothing. Fast path for all future renders.
554
569
  break;
555
570
  }
556
571
 
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "keywords": [
5
5
  "react"
6
6
  ],
7
- "version": "0.7.1",
7
+ "version": "0.7.2",
8
8
  "homepage": "https://reactjs.org/",
9
9
  "bugs": "https://github.com/facebook/react/issues",
10
10
  "license": "MIT",