Skip to content

Commit

Permalink
remove mapObject
Browse files Browse the repository at this point in the history
Reviewed By: josephsavona

Differential Revision: D27620782

fbshipit-source-id: 05001b0bf972481e3c8ad8c0ca1c5dc4b70702d1
  • Loading branch information
kassens authored and facebook-github-bot committed Apr 7, 2021
1 parent 4b9019b commit 4645888
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
4 changes: 0 additions & 4 deletions flow-typed/fbjs.js.flow
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
* @format
*/

declare module 'mapObject' {
declare module.exports: any;
}

declare module 'ErrorUtils' {
declare module.exports: any;
}
Expand Down
6 changes: 4 additions & 2 deletions packages/react-relay/buildReactRelayContainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const ReactRelayQueryRendererContext = require('./ReactRelayQueryRendererContext

const assertFragmentMap = require('./assertFragmentMap');
const invariant = require('invariant');
const mapObject = require('mapObject');
const readContext = require('./readContext');

const {
Expand Down Expand Up @@ -48,7 +47,10 @@ function buildReactRelayContainer<TBase: React$ComponentType<any>>(
const containerName = getContainerName(ComponentClass);
assertFragmentMap(getComponentName(ComponentClass), fragmentSpec);

const fragments = mapObject(fragmentSpec, getFragment);
const fragments = {};
for (const key in fragmentSpec) {
fragments[key] = getFragment(fragmentSpec[key]);
}
const Container = createContainerWithFragments(ComponentClass, fragments);
Container.displayName = containerName;

Expand Down
16 changes: 8 additions & 8 deletions packages/react-relay/relay-hooks/FragmentResource.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
const LRUCache = require('./LRUCache');

const invariant = require('invariant');
const mapObject = require('mapObject');

const {
__internal: {getPromiseForActiveRequest},
Expand Down Expand Up @@ -256,15 +255,16 @@ class FragmentResourceImpl {
fragmentRefs: {[string]: mixed, ...},
componentDisplayName: string,
): {[string]: FragmentResult, ...} {
return mapObject(fragmentNodes, (fragmentNode, fragmentKey) => {
const fragmentRef = fragmentRefs[fragmentKey];
return this.read(
fragmentNode,
fragmentRef,
const result = {};
for (const key in fragmentNodes) {
result[key] = this.read(
fragmentNodes[key],
fragmentRefs[key],
componentDisplayName,
fragmentKey,
key,
);
});
}
return result;
}

subscribe(fragmentResult: FragmentResult, callback: () => void): Disposable {
Expand Down
1 change: 0 additions & 1 deletion scripts/getBabelOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ module.exports = function(options) {
Promise: 'promise-polyfill',
areEqual: 'fbjs/lib/areEqual',
invariant: 'fbjs/lib/invariant',
mapObject: 'fbjs/lib/mapObject',
warning: 'fbjs/lib/warning',
},
},
Expand Down

0 comments on commit 4645888

Please sign in to comment.