Merge pull request #1565 from virtuacoplenny/lenny/defensive-classnames

fix(toolbox): Defensively check classNames when mapping button attrib…
This commit is contained in:
Saúl Ibarra Corretgé 2017-05-12 10:10:04 +02:00 committed by GitHub
commit b7c57d306a
1 changed files with 3 additions and 7 deletions

View File

@ -21,13 +21,9 @@ export { abstractMapStateToProps } from './functions.native';
*/
export function getButtonAttributesByProps(props: Object = {})
: MapOfAttributes {
let classNames = props.classNames;
if (classNames) {
// XXX Make sure to not modify props.classNames because that'd be bad
// practice.
classNames = [ ...classNames ];
}
const classNames = (props.classNames && [ ...props.classNames ]) || [];
props.toggled && classNames.push('toggled');
props.unclickable && classNames.push('unclickable');