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

Method constructor

src/components/connect.js:198–223  ·  view source on GitHub ↗
(props)

Source from the content-addressed store, hash-verified

196 return function wrapWithConnect(WrappedComponent) {
197 class RefetchConnect extends Component {
198 constructor(props) {
199 super(props)
200 this.version = version
201
202 // To avoid undefined data at mount, pre-populated pending PromiseStates
203 // TODO: de-dupe with update code
204 const mappings = finalMapPropsToRequestsToProps(omitChildren(props)) || {}
205 const initDate = Object.keys(mappings).reduce((data, prop) => {
206 const mapping = mappings[prop]
207 if (Function.prototype.isPrototypeOf(mapping)) {
208 data[prop] = (...args) => {
209 this.refetchDataFromMappings(mapping(...args))
210 }
211 } else {
212 data[prop] = PromiseState.create(mapping.meta)
213 }
214 return data
215 }, {})
216
217 this.state = {
218 mappings: {},
219 startedAts: {},
220 data: initDate,
221 refreshTimeouts: {}
222 }
223 }
224
225 componentDidMount() {
226 this.refetchDataFromProps()

Callers

nothing calls this directly

Calls 3

omitChildrenFunction · 0.85
createMethod · 0.65

Tested by

no test coverage detected