(getSystem, getStore, getComponents)
| 89 | } |
| 90 | |
| 91 | export const getComponent = (getSystem, getStore, getComponents) => (componentName, container, config = {}) => { |
| 92 | |
| 93 | if (typeof componentName !== "string") |
| 94 | throw new TypeError("Need a string, to fetch a component. Was given a " + typeof componentName) |
| 95 | |
| 96 | // getComponent has a config object as a third, optional parameter |
| 97 | // using the config object requires the presence of the second parameter, container |
| 98 | // e.g. getComponent("JsonSchema_string_whatever", false, { failSilently: true }) |
| 99 | const component = getComponents(componentName) |
| 100 | |
| 101 | if (!component) { |
| 102 | if (!config.failSilently) { |
| 103 | getSystem().log.warn("Could not find component:", componentName) |
| 104 | } |
| 105 | return null |
| 106 | } |
| 107 | |
| 108 | if(!container) { |
| 109 | return component |
| 110 | } |
| 111 | |
| 112 | if(container === "root") { |
| 113 | return withConnect(getSystem, component, getStore()) |
| 114 | } |
| 115 | |
| 116 | // container == truthy |
| 117 | return withConnect(getSystem, component) |
| 118 | } |
no test coverage detected
searching dependent graphs…