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

Remove side-effects from react-mocks #2584

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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