Skip to content

Commit

Permalink
Include actual type of Profiler#id on type mismatch
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Nov 20, 2020
1 parent 89d4fe1 commit 3f6b3a9
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
5 changes: 4 additions & 1 deletion packages/react-reconciler/src/ReactFiber.new.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,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,
);
}
}

Expand Down
5 changes: 4 additions & 1 deletion packages/react-reconciler/src/ReactFiber.old.js
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,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,
);
}
}

Expand Down
9 changes: 6 additions & 3 deletions packages/react/src/__tests__/ReactProfiler-test.internal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
);
});
}

Expand Down

0 comments on commit 3f6b3a9

Please sign in to comment.