diff --git a/packages/classnames/classnames.tsx b/packages/classnames/classnames.tsx index 32207789..18db0a77 100644 --- a/packages/classnames/classnames.tsx +++ b/packages/classnames/classnames.tsx @@ -11,18 +11,24 @@ * * @param strings classNames strings */ -export function classnames(...strings: Array) { +export function classnames(...strings: Array): string; +export function classnames() { let className = ''; const uniqueCache = new Set(); - const classNameList = strings.join(' ').split(' '); + // Use arguments instead rest operator for better performance. + const classNameList: Array = [].slice.call(arguments); for (const value of classNameList) { - if (value === '' || uniqueCache.has(value)) { + if (value === '' || value === undefined || uniqueCache.has(value)) { continue; } uniqueCache.add(value); - if (className.length > 0) className += ' '; + + if (className.length > 0) { + className += ' '; + } + className += value; }