housekeeping: prevent log warning for missing getComponent in production

This is a force-pushed squash of two PR merges (#5919, #5940) that were
formerly present on master as individual commits.

Co-Authored-By: kyle shockey <kyleshockey@gmail.com>
This commit is contained in:
Timothy Lai
2020-04-04 18:46:09 -04:00
committed by Kyle Shockey
parent 12e86dafb0
commit 0426eb2344
2 changed files with 15 additions and 3 deletions

View File

@@ -101,15 +101,20 @@ const wrapRender = (component) => {
}
export const getComponent = (getSystem, getStore, getComponents, componentName, container) => {
export const getComponent = (getSystem, getStore, getComponents, componentName, container, config = {}) => {
if(typeof componentName !== "string")
throw new TypeError("Need a string, to fetch a component. Was given a " + typeof componentName)
// getComponent has a config object as a third, optional parameter
// using the config object requires the presence of the second parameter, container
// e.g. getComponent("JsonSchema_string_whatever", false, { failSilently: true })
let component = getComponents(componentName)
if(!component) {
getSystem().log.warn("Could not find component", componentName)
if (!config.failSilently) {
getSystem().log.warn("Could not find component:", componentName)
}
return null
}