semantic-ui-calendar-react
Version:
date/time picker built from semantic-ui elements
19 lines (16 loc) • 721 B
JavaScript
/**
* Returns an object consisting of props beyond the scope of the Component.
* Useful for getting and spreading unknown props from the user.
* @param {function} Component A function or ReactClass.
* @param {object} props A ReactElement props object
* @returns {{}} A shallow copy of the prop object
*/
const getUnhandledProps = (Component, props) => {
// Note that `handledProps` are generated automatically during build with `babel-plugin-transform-react-handled-props`
const { handledProps = [] } = Component;
return Object.keys(props).reduce((acc, propKey) => {
if (handledProps.indexOf(propKey) === -1) acc[propKey] = props[propKey];
return acc;
}, {});
};
export default getUnhandledProps;