MCPcopy
hub / github.com/swagger-api/swagger-ui / getComponent

Function getComponent

src/core/plugins/view/root-injects.jsx:91–118  ·  view source on GitHub ↗
(getSystem, getStore, getComponents)

Source from the content-addressed store, hash-verified

89}
90
91export 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}

Callers 15

viewPluginFunction · 0.90
renderMethod · 0.85
renderMethod · 0.85
renderMethod · 0.85
renderMethod · 0.85
renderMethod · 0.85
renderMethod · 0.85
renderMethod · 0.85
renderMethod · 0.85
renderMethod · 0.85
OperationExtFunction · 0.85
renderMethod · 0.85

Calls 2

withConnectFunction · 0.85
getSystemFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…