react-carousel-query
Version:
A infinite carousel component made with react that handles the pagination for you.
27 lines (19 loc) • 621 B
Flow
/* @flow */
const isKeyOrRefProps = (propName: string) => ['key', 'ref'].includes(propName);
export default (shouldSortUserProps: boolean) => (
props: string[]
): string[] => {
const haveKeyProp = props.includes('key');
const haveRefProp = props.includes('ref');
const userPropsOnly = props.filter(oneProp => !isKeyOrRefProps(oneProp));
const sortedProps = shouldSortUserProps
? [...userPropsOnly.sort()] // We use basic lexical order
: [...userPropsOnly];
if (haveRefProp) {
sortedProps.unshift('ref');
}
if (haveKeyProp) {
sortedProps.unshift('key');
}
return sortedProps;
};