Skip to content

Commit

Permalink
feat(components): remove ref types for SSR compatibility
Browse files Browse the repository at this point in the history
The ref prop types used instances of HTML elements that are not available in Node. This broke
server-side rendering (SSR).

beta
  • Loading branch information
connor-baer committed Jul 2, 2020
1 parent cc731e0 commit 08e604e
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/components/Checkbox/Checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ Checkbox.propTypes = {
ref: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({
current: PropTypes.oneOf([PropTypes.instanceOf(HTMLInputElement)])
current: PropTypes.any
})
])
};
Expand Down
7 changes: 5 additions & 2 deletions src/components/ComponentsContext/components/Link/Link.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

import React from 'react';
import { oneOfType, func, shape, instanceOf } from 'prop-types';
import PropTypes from 'prop-types';

import { childrenPropType } from '../../../../util/shared-prop-types';

Expand All @@ -30,7 +30,10 @@ const Link = React.forwardRef(LinkComponent);

Link.propTypes = {
children: childrenPropType,
ref: oneOfType([func, shape({ current: instanceOf(HTMLAnchorElement) })])
ref: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({ current: PropTypes.any })
])
};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/components/RadioButton/RadioButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ RadioButton.propTypes = {
ref: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({
current: PropTypes.oneOf([PropTypes.instanceOf(HTMLInputElement)])
current: PropTypes.any
})
])
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/Tag/Tag.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ Tag.propTypes = {
ref: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({
current: PropTypes.oneOf([PropTypes.instanceOf(HTMLButtonElement)])
current: PropTypes.any
})
])
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/Toggle/Toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Toggle.propTypes = {
ref: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({
current: PropTypes.oneOf([PropTypes.instanceOf(HTMLButtonElement)])
current: PropTypes.any
})
])
};
Expand Down
2 changes: 1 addition & 1 deletion src/components/Toggle/components/Switch/Switch.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Switch.propTypes = {
ref: PropTypes.oneOfType([
PropTypes.func,
PropTypes.shape({
current: PropTypes.oneOf([PropTypes.instanceOf(HTMLButtonElement)])
current: PropTypes.any
})
])
};
Expand Down

0 comments on commit 08e604e

Please sign in to comment.