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

Commit

Permalink
Unknown Prop Warning on ResponsiveNavigation Component (#57)
Browse files Browse the repository at this point in the history
* GridContainer full / fluid generates render warning from React (#55)

* Unknown Prop Warning on ResponsiveNavigation Component (#23)
  • Loading branch information
bobwalker99 authored and crisu83 committed Mar 7, 2018
1 parent 32ed8d2 commit a8206fb
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 5 deletions.
28 changes: 24 additions & 4 deletions src/components/responsive.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import { TopBar } from './top-bar';
import { GeneralPropTypes, FlexboxPropTypes, createClassName, generalClassNames, removeProps } from '../utils';
import { GeneralPropTypes, FlexboxPropTypes, createClassName, generalClassNames, removeProps, objectKeys } from '../utils';
import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment';

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

const passProps = removeProps(props, objectKeys(TitleBar.propTypes));

return (
<div {...props} className={className}/>
<div {...passProps} className={className} />
);

};

TitleBar.propTypes = {
...GeneralPropTypes,
...FlexboxPropTypes
};

/**
Expand All @@ -133,12 +141,18 @@ export const MenuIcon = props => {
props.className,
generalClassNames(props)
);
const passProps = removeProps(props, objectKeys(MenuIcon.propTypes));

return (
<button {...props} className={className} type="button"/>
<button {...passProps} className={className} type="button"/>
);
};

MenuIcon.propTypes = {
...GeneralPropTypes,
...FlexboxPropTypes
};

/**
* Title bar title sub-component.
*
Expand All @@ -152,7 +166,13 @@ export const TitleBarTitle = props => {
generalClassNames(props)
);

const passProps = removeProps(props, objectKeys(TitleBarTitle.propTypes));
return (
<div {...props} className={className}/>
<div {...passProps} className={className}/>
);
};

TitleBarTitle.propTypes = {
...GeneralPropTypes,
...FlexboxPropTypes
};
15 changes: 14 additions & 1 deletion test/components/responsive-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@ describe('TitleBar component', () => {
const component = render(<TitleBar className="my-title-bar"/>);
expect(component).to.have.className('my-title-bar');
});

it('does not carry over non-DOM props', () => {
const component = shallow(<TitleBar isHidden={true} />);
expect(component).to.not.have.prop('isHidden');
});
});

describe('MenuIcon component', () => {
Expand Down Expand Up @@ -136,6 +139,11 @@ describe('MenuIcon component', () => {
expect(component).to.have.text('Icon');
});

it('does not carry over non-DOM props', () => {
const component = shallow(<MenuIcon isHidden={true} />);
expect(component).to.not.have.prop('isHidden');
});

});

describe('TitleBarTitle component', () => {
Expand Down Expand Up @@ -165,4 +173,9 @@ describe('TitleBarTitle component', () => {
expect(component).to.have.text('Menu');
});

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

});

0 comments on commit a8206fb

Please sign in to comment.