@samitouri / QOS-React / commits / 75c616554d

Include actual type of `Profiler#id` on type mismatch (#20306)

Sebastian Silbermann committed Apr 8, 2021 at 19:36 UTC 75c616554d06bfd2c82108ad0c0196d674c72ba9
3 files changed +14 -5
packages/react-reconciler/src/ReactFiber.new.js
+4 -1
@@ -651,7 +651,10 @@ function createFiberFromProfiler(
651 ): Fiber {
652 if (__DEV__) {
653 if (typeof pendingProps.id !== 'string') {
654 - console.error('Profiler must specify an "id" as a prop');
654 + console.error(
655 + 'Profiler must specify an "id" of type `string` as a prop. Received the type `%s` instead.',
656 + typeof pendingProps.id,
657 + );
658 }
659 }
660
packages/react-reconciler/src/ReactFiber.old.js
+4 -1
@@ -651,7 +651,10 @@ function createFiberFromProfiler(
651 ): Fiber {
652 if (__DEV__) {
653 if (typeof pendingProps.id !== 'string') {
654 - console.error('Profiler must specify an "id" as a prop');
654 + console.error(
655 + 'Profiler must specify an "id" of type `string` as a prop. Received the type `%s` instead.',
656 + typeof pendingProps.id,
657 + );
658 }
659 }
660
packages/react/src/__tests__/ReactProfiler-test.internal.js
+6 -3
@@ -136,9 +136,12 @@ describe('Profiler', () => {
136 it('should warn if required params are missing', () => {
137 expect(() => {
138 ReactTestRenderer.create(<React.Profiler />);
139 - }).toErrorDev('Profiler must specify an "id" as a prop', {
140 - withoutStack: true,
141 - });
139 + }).toErrorDev(
140 + 'Profiler must specify an "id" of type `string` as a prop. Received the type `undefined` instead.',
141 + {
142 + withoutStack: true,
143 + },
144 + );
145 });
146 }
147