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

Commit a8206fb

Browse files
bobwalker99crisu83
authored andcommitted
Unknown Prop Warning on ResponsiveNavigation Component (#57)
* GridContainer full / fluid generates render warning from React (#55) * Unknown Prop Warning on ResponsiveNavigation Component (#23)
1 parent 32ed8d2 commit a8206fb

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

src/components/responsive.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { Component } from 'react';
22
import PropTypes from 'prop-types';
33
import { TopBar } from './top-bar';
4-
import { GeneralPropTypes, FlexboxPropTypes, createClassName, generalClassNames, removeProps } from '../utils';
4+
import { GeneralPropTypes, FlexboxPropTypes, createClassName, generalClassNames, removeProps, objectKeys } from '../utils';
55
import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment';
66

77
// Default pixel value when title bar is displayed and top bar is hidden.
@@ -116,9 +116,17 @@ export const TitleBar = props => {
116116
generalClassNames(props)
117117
);
118118

119+
const passProps = removeProps(props, objectKeys(TitleBar.propTypes));
120+
119121
return (
120-
<div {...props} className={className}/>
122+
<div {...passProps} className={className} />
121123
);
124+
125+
};
126+
127+
TitleBar.propTypes = {
128+
...GeneralPropTypes,
129+
...FlexboxPropTypes
122130
};
123131

124132
/**
@@ -133,12 +141,18 @@ export const MenuIcon = props => {
133141
props.className,
134142
generalClassNames(props)
135143
);
144+
const passProps = removeProps(props, objectKeys(MenuIcon.propTypes));
136145

137146
return (
138-
<button {...props} className={className} type="button"/>
147+
<button {...passProps} className={className} type="button"/>
139148
);
140149
};
141150

151+
MenuIcon.propTypes = {
152+
...GeneralPropTypes,
153+
...FlexboxPropTypes
154+
};
155+
142156
/**
143157
* Title bar title sub-component.
144158
*
@@ -152,7 +166,13 @@ export const TitleBarTitle = props => {
152166
generalClassNames(props)
153167
);
154168

169+
const passProps = removeProps(props, objectKeys(TitleBarTitle.propTypes));
155170
return (
156-
<div {...props} className={className}/>
171+
<div {...passProps} className={className}/>
157172
);
158173
};
174+
175+
TitleBarTitle.propTypes = {
176+
...GeneralPropTypes,
177+
...FlexboxPropTypes
178+
};

test/components/responsive-spec.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,10 @@ describe('TitleBar component', () => {
101101
const component = render(<TitleBar className="my-title-bar"/>);
102102
expect(component).to.have.className('my-title-bar');
103103
});
104-
104+
it('does not carry over non-DOM props', () => {
105+
const component = shallow(<TitleBar isHidden={true} />);
106+
expect(component).to.not.have.prop('isHidden');
107+
});
105108
});
106109

107110
describe('MenuIcon component', () => {
@@ -136,6 +139,11 @@ describe('MenuIcon component', () => {
136139
expect(component).to.have.text('Icon');
137140
});
138141

142+
it('does not carry over non-DOM props', () => {
143+
const component = shallow(<MenuIcon isHidden={true} />);
144+
expect(component).to.not.have.prop('isHidden');
145+
});
146+
139147
});
140148

141149
describe('TitleBarTitle component', () => {
@@ -165,4 +173,9 @@ describe('TitleBarTitle component', () => {
165173
expect(component).to.have.text('Menu');
166174
});
167175

176+
it('does not carry over non-DOM props', () => {
177+
const component = shallow(<TitleBarTitle isHidden={true} />);
178+
expect(component).to.not.have.prop('isHidden');
179+
});
180+
168181
});

0 commit comments

Comments
 (0)