Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit 272a217

Browse files
nersohthemariamarques
authored andcommitted
fix: change Responsive Provider proptypes
1 parent 51136a0 commit 272a217

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

src/ResponsiveProvider.js

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -139,28 +139,39 @@ const ResponsiveProvider = ({
139139
);
140140
};
141141

142+
const breakpointsPropTypes = {
143+
xs: PropTypes.string,
144+
sm: PropTypes.string,
145+
md: PropTypes.string,
146+
lg: PropTypes.string,
147+
xl: PropTypes.string,
148+
};
149+
142150
ResponsiveProvider.defaultProps = {
143151
initialMediaType: 'xs',
144152
defaultOrientation: null,
145153
};
146154

147155
ResponsiveProvider.propTypes = {
148-
initialMediaType: PropTypes.string,
149-
defaultOrientation: PropTypes.string,
156+
initialMediaType: PropTypes.oneOf([
157+
'_initial',
158+
'xs',
159+
'sm',
160+
'md',
161+
'lg',
162+
'xl',
163+
]),
164+
defaultOrientation: PropTypes.oneOf(['landscape', 'portrait']),
150165
children: PropTypes.oneOfType([
151166
PropTypes.arrayOf(PropTypes.node),
152167
PropTypes.node,
153168
]).isRequired,
154-
breakpoints: PropTypes.arrayOf(
155-
PropTypes.shape({
156-
mediaQuery: PropTypes.string,
157-
mediaType: PropTypes.string,
158-
})
159-
),
160-
// eslint-disable-next-line react/forbid-prop-types
161-
mediaQueries: PropTypes.any,
162-
// eslint-disable-next-line react/forbid-prop-types
163-
breakpointsMax: PropTypes.any,
169+
breakpoints: PropTypes.exact(breakpointsPropTypes),
170+
breakpointsMax: PropTypes.exact(breakpointsPropTypes),
171+
mediaQueries: PropTypes.exact({
172+
...breakpointsPropTypes,
173+
_initial: PropTypes.string,
174+
}),
164175
};
165176

166177
export default ResponsiveProvider;

0 commit comments

Comments
 (0)