Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export const getPropsTableProps = (
{ exclude, of }: PropsProps,
{ parameters, getPropDefs }: DocsContextProps
): PropsTableProps => {
const { component } = parameters;
try {
const target = of || component;
if (!target) {
throw new Error(PropsTableError.NO_COMPONENT);
}
if (!getPropDefs) {
throw new Error(PropsTableError.PROPS_UNSUPPORTED);
}
const allRows = getPropDefs(target);
const rows = !exclude ? allRows : allRows.filter(row => !exclude.includes(row.name));
return { rows };
} catch (err) {
return { error: err.message };
}
};