MCPcopy Index your code
hub / github.com/reactopt/reactopt / createComponentDidUpdate

Function createComponentDidUpdate

src/index.js:27–57  ·  view source on GitHub ↗
(opts)

Source from the content-addressed store, hash-verified

25// monkeypatch
26// ****** called on render -> look down to opts.notifier
27function createComponentDidUpdate(opts) {
28 return function componentDidUpdate(prevProps, prevState) {
29 //displayname is component name
30 var displayName = (0, _getDisplayName.getDisplayName)(this);
31
32 //should include returns display/comp name, if return value doesn't exist exit compDidUpdate w/o doing anything
33 if (!(0, _shouldInclude.shouldInclude)(displayName, opts)) {
34 return;
35 }
36
37 var propsDiff = (0, _deepDiff.classifyDiff)(prevProps, this.props, displayName + '.props');
38 if (propsDiff.type === _deepDiff.DIFF_TYPES.UNAVOIDABLE) {
39 return;
40 }
41
42 var stateDiff = (0, _deepDiff.classifyDiff)(prevState, this.state, displayName + '.state');
43 if (stateDiff.type === _deepDiff.DIFF_TYPES.UNAVOIDABLE) {
44 return;
45 }
46 //if makes it past above non-conflicts (meaning there are components re-rendering unnecessarily)
47 // temp timeout because event listener sets global event names after components re-render
48 setTimeout(timeTest,100);
49 function timeTest() {
50 console.log('data!!!',window.data);
51
52 // storing event data in window's 'data' object
53 let len = (window.data.rerenders).length - 1;
54 window.data.rerenders[len].components.push(displayName);
55 }
56 };
57}
58
59// takes in react component, triggers all other logic, is exported out
60var whyDidYouUpdate = function whyDidYouUpdate(React) {

Callers 1

whyDidYouUpdateFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected