Skip to content

Commit 3f6b3a9

Browse files
committed
Include actual type of Profiler#id on type mismatch
1 parent 89d4fe1 commit 3f6b3a9

File tree

3 files changed

+14
-5
lines changed

3 files changed

+14
-5
lines changed

packages/react-reconciler/src/ReactFiber.new.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,10 @@ function createFiberFromProfiler(
650650
): Fiber {
651651
if (__DEV__) {
652652
if (typeof pendingProps.id !== 'string') {
653-
console.error('Profiler must specify an "id" as a prop');
653+
console.error(
654+
'Profiler must specify an "id" of type `string` as a prop. Received the type `%s` instead.',
655+
typeof pendingProps.id,
656+
);
654657
}
655658
}
656659

packages/react-reconciler/src/ReactFiber.old.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,7 +650,10 @@ function createFiberFromProfiler(
650650
): Fiber {
651651
if (__DEV__) {
652652
if (typeof pendingProps.id !== 'string') {
653-
console.error('Profiler must specify an "id" as a prop');
653+
console.error(
654+
'Profiler must specify an "id" of type `string` as a prop. Received the type `%s` instead.',
655+
typeof pendingProps.id,
656+
);
654657
}
655658
}
656659

packages/react/src/__tests__/ReactProfiler-test.internal.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,12 @@ describe('Profiler', () => {
136136
it('should warn if required params are missing', () => {
137137
expect(() => {
138138
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+
);
142145
});
143146
}
144147

0 commit comments

Comments
 (0)