MCPcopy
hub / github.com/heroku/react-refetch / assignDefaults

Function assignDefaults

src/components/connect.js:165–194  ·  view source on GitHub ↗
(mapping, parent)

Source from the content-addressed store, hash-verified

163 }
164
165 function assignDefaults(mapping, parent) {
166 const rawHeaders = Object.assign({}, defaults.headers, mapping.headers)
167 const headers = {}
168 for (let key in rawHeaders) {
169 // Discard headers with falsy values
170 if (rawHeaders.hasOwnProperty(key) && rawHeaders[key]) {
171 // Get the value now if the header is specified as a function
172 const headerValue = typeof rawHeaders[key] == 'function' ? rawHeaders[key]() : rawHeaders[key]
173 headers[key] = headerValue
174 }
175 }
176
177 return Object.assign(
178 {
179 meta: {}
180 },
181 defaults,
182 parent ? {
183 fetch: parent.fetch,
184 buildRequest: parent.buildRequest,
185 handleResponse: parent.handleResponse,
186 Request: parent.Request,
187 comparison: parent.comparison,
188 then: undefined,
189 andThen: undefined
190 } : {},
191 mapping,
192 { headers }
193 )
194 }
195
196 return function wrapWithConnect(WrappedComponent) {
197 class RefetchConnect extends Component {

Callers 1

coerceMappingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…