Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function getComponentFn(component, fnName) {
if (isFunction(component[fnName])) {
return component[fnName].bind(component);
} else {
console.error(`No function named ${fnName} was found in the component
"${getFunctionName(component.constructor)}". Make sure that you specify
valid function names when adding inline listeners`
);
}
}
function composeError(error, name, context) {
const compName = context ? getFunctionName(context.constructor) : null;
const renderer = context && context.getRenderer && context.getRenderer();
const parent = renderer && renderer.getParent && renderer.getParent();
const parentName = parent ? getFunctionName(parent.constructor) : null;
const location = parentName
? `Check render method of '${parentName}'.`
: '';
return new Error(
`Invalid state passed to '${name}'.` +
` ${error} Passed to '${compName}'. ${location}`
);
}
function composeError(error, name, context) {
const compName = context ? getFunctionName(context.constructor) : null;
const renderer = context && context.getRenderer && context.getRenderer();
const parent = renderer && renderer.getParent && renderer.getParent();
const parentName = parent ? getFunctionName(parent.constructor) : null;
const location = parentName
? `Check render method of '${parentName}'.`
: '';
return new Error(
`Invalid state passed to '${name}'.` +
` ${error} Passed to '${compName}'. ${location}`
);
}
static register(constructorFn, opt_name) {
let name = opt_name;
if (!name) {
if (constructorFn.hasOwnProperty('NAME')) {
name = constructorFn.NAME;
} else {
name = getFunctionName(constructorFn);
}
}
constructorFn.NAME = name;
ComponentRegistry.components_[name] = constructorFn;
}
}