Skip to content

Commit c486479

Browse files
committed
[Shallow] Rename effect cleanup function to destroy to match rest of react (facebook#15275)
1 parent b029466 commit c486479

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

packages/react-test-renderer/src/ReactShallowRenderer.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ class ReactShallowRenderer {
333333
isLayoutEffect,
334334
create,
335335
inputs,
336-
cleanup: null,
336+
destroy: null,
337337
run: true,
338338
};
339339
} else {
@@ -343,7 +343,7 @@ class ReactShallowRenderer {
343343
isLayoutEffect,
344344
create,
345345
inputs,
346-
cleanup: memoizedState.cleanup,
346+
destroy: memoizedState.destroy,
347347
run:
348348
inputs == null ||
349349
!areHookInputsEqual(inputs, memoizedState.inputs),
@@ -754,10 +754,10 @@ class ReactShallowRenderer {
754754
memoizedState.isLayoutEffect === callLayoutEffects &&
755755
memoizedState.run
756756
) {
757-
if (memoizedState.cleanup) {
758-
memoizedState.cleanup();
757+
if (memoizedState.destroy) {
758+
memoizedState.destroy();
759759
}
760-
memoizedState.cleanup = memoizedState.create();
760+
memoizedState.destroy = memoizedState.create();
761761
}
762762
}
763763
}

packages/react-test-renderer/src/__tests__/ReactShallowRendererHooks-test.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ describe('ReactShallowRenderer with hooks', () => {
281281
]);
282282
});
283283

284-
it('should trigger effects and cleanup depending on inputs', () => {
284+
it('should trigger effects and destroy depending on inputs', () => {
285285
let _setFriend;
286286
const happenings = [];
287287

@@ -294,7 +294,7 @@ describe('ReactShallowRenderer with hooks', () => {
294294
() => {
295295
happenings.push('call friend effect');
296296
return () => {
297-
happenings.push('cleanup friend effect');
297+
happenings.push('destroy friend effect');
298298
};
299299
},
300300
[friend],
@@ -303,15 +303,15 @@ describe('ReactShallowRenderer with hooks', () => {
303303
React.useEffect(() => {
304304
happenings.push('call empty effect');
305305
return () => {
306-
happenings.push('cleanup empty effect');
306+
happenings.push('destroy empty effect');
307307
};
308308
});
309309

310310
React.useEffect(
311311
() => {
312312
happenings.push('call cat effect');
313313
return () => {
314-
happenings.push('cleanup cat effect');
314+
happenings.push('destroy cat effect');
315315
};
316316
},
317317
[cat],
@@ -321,7 +321,7 @@ describe('ReactShallowRenderer with hooks', () => {
321321
() => {
322322
happenings.push('call both effect');
323323
return () => {
324-
happenings.push('cleanup both effect');
324+
happenings.push('destroy both effect');
325325
};
326326
},
327327
[friend, cat],
@@ -347,11 +347,11 @@ describe('ReactShallowRenderer with hooks', () => {
347347
happenings.splice(0);
348348
_setFriend('Maryam');
349349
expect(happenings).toEqual([
350-
'cleanup friend effect',
350+
'destroy friend effect',
351351
'call friend effect',
352-
'cleanup empty effect',
352+
'destroy empty effect',
353353
'call empty effect',
354-
'cleanup both effect',
354+
'destroy both effect',
355355
'call both effect',
356356
]);
357357
});

0 commit comments

Comments
 (0)