Include actual type of `Profiler#id` on type mismatch (#20306)
This commit is contained in:
parent
1214b302e1
commit
75c616554d
|
@ -651,7 +651,10 @@ function createFiberFromProfiler(
|
|||
): Fiber {
|
||||
if (__DEV__) {
|
||||
if (typeof pendingProps.id !== 'string') {
|
||||
console.error('Profiler must specify an "id" as a prop');
|
||||
console.error(
|
||||
'Profiler must specify an "id" of type `string` as a prop. Received the type `%s` instead.',
|
||||
typeof pendingProps.id,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -651,7 +651,10 @@ function createFiberFromProfiler(
|
|||
): Fiber {
|
||||
if (__DEV__) {
|
||||
if (typeof pendingProps.id !== 'string') {
|
||||
console.error('Profiler must specify an "id" as a prop');
|
||||
console.error(
|
||||
'Profiler must specify an "id" of type `string` as a prop. Received the type `%s` instead.',
|
||||
typeof pendingProps.id,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -136,9 +136,12 @@ describe('Profiler', () => {
|
|||
it('should warn if required params are missing', () => {
|
||||
expect(() => {
|
||||
ReactTestRenderer.create(<React.Profiler />);
|
||||
}).toErrorDev('Profiler must specify an "id" as a prop', {
|
||||
withoutStack: true,
|
||||
});
|
||||
}).toErrorDev(
|
||||
'Profiler must specify an "id" of type `string` as a prop. Received the type `undefined` instead.',
|
||||
{
|
||||
withoutStack: true,
|
||||
},
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue