fix(toolbox): Defensively check classNames when mapping button attributes

This commit is contained in:
Leonard Kim 2017-05-11 14:35:33 -07:00
parent 2f3706bd37
commit 816eef1702
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 = {}) export function getButtonAttributesByProps(props: Object = {})
: MapOfAttributes { : MapOfAttributes {
let classNames = props.classNames; // XXX Make sure to not modify props.classNames because that'd be bad
// practice.
if (classNames) { const classNames = (props.classNames && [ ...props.classNames ]) || [];
// XXX Make sure to not modify props.classNames because that'd be bad
// practice.
classNames = [ ...classNames ];
}
props.toggled && classNames.push('toggled'); props.toggled && classNames.push('toggled');
props.unclickable && classNames.push('unclickable'); props.unclickable && classNames.push('unclickable');