Skip to content

Commit

Permalink
fixup! fixup! fixup! Update blacklisted props that can be passed to n…
Browse files Browse the repository at this point in the history
…ative HTML elements using the transferProps principle
  • Loading branch information
mbohal committed Feb 14, 2024
1 parent 3c8ab8f commit 37cc991
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
9 changes: 9 additions & 0 deletions src/components/_helpers/__tests__/transferProps.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,16 @@ describe('transferProps', () => {
staticContext: 'value',
};
const expectedProps = {};
let errorString;

const originalConsoleError = console.error;

Check warning on line 25 in src/components/_helpers/__tests__/transferProps.test.js

View workflow job for this annotation

GitHub Actions / Lint

Unexpected console statement

console.error = (error) => {

Check warning on line 27 in src/components/_helpers/__tests__/transferProps.test.js

View workflow job for this annotation

GitHub Actions / Lint

Unexpected console statement
errorString = error;
};
expect(transferProps(props)).toEqual(expectedProps);
expect(errorString).toEqual('Invalid prop(s) supplied to the "transferProps" function: "children", "className", "ref", "staticContext"');

console.error = originalConsoleError;

Check warning on line 33 in src/components/_helpers/__tests__/transferProps.test.js

View workflow job for this annotation

GitHub Actions / Lint

Unexpected console statement
});
});
20 changes: 10 additions & 10 deletions src/components/_helpers/transferProps.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@ export const transferProps = (props) => {
} = props;

if (process.env.NODE_ENV !== 'production') {
const invalidProps = Object.keys({
children,
className,
contentEditable,
dangerouslySetInnerHTML,
ref,
staticContext,
style,
suppressContentEditableWarning,
})
const invalidProps = [
'children',
'className',
'contentEditable',
'dangerouslySetInnerHTML',
'ref',
'staticContext',
'style',
'suppressContentEditableWarning',
]
.filter((key) => props[key] !== undefined);

if (invalidProps.length > 0) {
Expand Down

0 comments on commit 37cc991

Please sign in to comment.