Skip to content
This repository has been archived by the owner on Feb 12, 2022. It is now read-only.

Commit

Permalink
Remove side-effects from react-mocks (#2584)
Browse files Browse the repository at this point in the history
Summary:
Release notes: none

Some internal changes to the `react-mocks` where side-effects were observed in small cases that needed tweaking (only affects internal React testing).
Pull Request resolved: #2584

Differential Revision: D10147064

Pulled By: trueadm

fbshipit-source-id: bb4c196ae6f03abdc1c2e39b27b740a21989b61f
  • Loading branch information
trueadm authored and facebook-github-bot committed Oct 2, 2018
1 parent 5fc6fee commit 4f250d1
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/intrinsics/fb-www/react-mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,6 @@ let reactCode = `
};
}
function releaseTraverseContext(traverseContext) {
traverseContext.result = null;
traverseContext.keyPrefix = null;
traverseContext.func = null;
traverseContext.context = null;
traverseContext.count = 0;
}
function traverseAllChildren(children, callback, traverseContext) {
if (children == null) {
return 0;
Expand Down Expand Up @@ -270,7 +262,7 @@ let reactCode = `
function mapSingleChildIntoContext(bookKeeping, child, childKey) {
var {result, keyPrefix, func, context} = bookKeeping;
let mappedChild = func.call(context, child, bookKeeping.count++);
let mappedChild = func.call(context, child);
if (Array.isArray(mappedChild)) {
mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, c => c);
} else if (mappedChild != null) {
Expand Down Expand Up @@ -302,12 +294,11 @@ let reactCode = `
context,
);
traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
releaseTraverseContext(traverseContext);
}
function forEachSingleChild(bookKeeping, child, name) {
var {func, context} = bookKeeping;
func.call(context, child, bookKeeping.count++);
func.call(context, child);
}
function forEachChildren(children, forEachFunc, forEachContext) {
Expand All @@ -321,7 +312,6 @@ let reactCode = `
forEachContext,
);
traverseAllChildren(children, forEachSingleChild, traverseContext);
releaseTraverseContext(traverseContext);
}
function mapChildren(children, func, context) {
Expand Down

0 comments on commit 4f250d1

Please sign in to comment.