MCPcopy Create free account
hub / github.com/microsoft/SandDance / warnOnHookMismatchInDev

Function warnOnHookMismatchInDev

docs/external/js/react-dom.development.js:14825–14854  ·  view source on GitHub ↗
(currentHookName)

Source from the content-addressed store, hash-verified

14823 }
14824
14825 function warnOnHookMismatchInDev(currentHookName) {
14826 {
14827 var componentName = getComponentName(currentlyRenderingFiber$1.type);
14828
14829 if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) {
14830 didWarnAboutMismatchedHooksForComponent.add(componentName);
14831
14832 if (hookTypesDev !== null) {
14833 var table = '';
14834 var secondColumnStart = 30;
14835
14836 for (var i = 0; i <= hookTypesUpdateIndexDev; i++) {
14837 var oldHookName = hookTypesDev[i];
14838 var newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName;
14839 var row = i + 1 + ". " + oldHookName; // Extra space so second column lines up
14840 // lol @ IE not supporting String#repeat
14841
14842 while (row.length < secondColumnStart) {
14843 row += ' ';
14844 }
14845
14846 row += newHookName + '\n';
14847 table += row;
14848 }
14849
14850 error('React has detected a change in the order of Hooks called by %s. ' + 'This will lead to bugs and errors if not fixed. ' + 'For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n' + ' Previous render Next render\n' + ' ------------------------------------------------------\n' + '%s' + ' ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n', componentName, table);
14851 }
14852 }
14853 }
14854 }
14855
14856 function throwInvalidHookError() {
14857 {

Callers 1

updateHookTypesDevFunction · 0.85

Calls 4

getComponentNameFunction · 0.70
errorFunction · 0.70
hasMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected