MCPcopy Index your code
hub / github.com/microsoft/SandDance / commitHookEffectListMount

Function commitHookEffectListMount

docs/external/js/react-dom.development.js:19854–19890  ·  view source on GitHub ↗
(tag, finishedWork)

Source from the content-addressed store, hash-verified

19852 }
19853
19854 function commitHookEffectListMount(tag, finishedWork) {
19855 var updateQueue = finishedWork.updateQueue;
19856 var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
19857
19858 if (lastEffect !== null) {
19859 var firstEffect = lastEffect.next;
19860 var effect = firstEffect;
19861
19862 do {
19863 if ((effect.tag & tag) === tag) {
19864 // Mount
19865 var create = effect.create;
19866 effect.destroy = create();
19867
19868 {
19869 var destroy = effect.destroy;
19870
19871 if (destroy !== undefined && typeof destroy !== 'function') {
19872 var addendum = void 0;
19873
19874 if (destroy === null) {
19875 addendum = ' You returned null. If your effect does not require clean ' + 'up, return undefined (or nothing).';
19876 } else if (typeof destroy.then === 'function') {
19877 addendum = '\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. ' + 'Instead, write the async function inside your effect ' + 'and call it immediately:\n\n' + 'useEffect(() => {\n' + ' async function fetchData() {\n' + ' // You can await here\n' + ' const response = await MyAPI.getData(someId);\n' + ' // ...\n' + ' }\n' + ' fetchData();\n' + "}, [someId]); // Or [] if effect doesn't need props or state\n\n" + 'Learn more about data fetching with Hooks: https://fb.me/react-hooks-data-fetching';
19878 } else {
19879 addendum = ' You returned: ' + destroy;
19880 }
19881
19882 error('An effect function must not return anything besides a function, ' + 'which is used for clean-up.%s%s', addendum, getStackByFiberInDevAndProd(finishedWork));
19883 }
19884 }
19885 }
19886
19887 effect = effect.next;
19888 } while (effect !== firstEffect);
19889 }
19890 }
19891
19892 function commitPassiveHookEffects(finishedWork) {
19893 if ((finishedWork.effectTag & Passive) !== NoEffect) {

Callers 2

commitPassiveHookEffectsFunction · 0.85
commitLifeCyclesFunction · 0.85

Calls 3

errorFunction · 0.70
createFunction · 0.50

Tested by

no test coverage detected