Skip to content

Commit 83e3b89

Browse files
author
Juan Tejada
committed
Add extra comments about extension fields
1 parent 2887765 commit 83e3b89

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

packages/react-devtools-extensions/src/__tests__/updateMockSourceMaps.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,15 @@ function compile(fileName) {
133133
const encodedHookMap = generateEncodedHookMap(parsed);
134134
const fbSourcesExtendedSourceMap = {
135135
...sourceMap,
136+
// When using the x_fb_sources extension field, the first item
137+
// for a given source is reserved for the Function Map, and the
138+
// Hook Map is added as the second item.
136139
x_fb_sources: [[null, encodedHookMap]],
137140
};
138141
const reactSourcesExtendedSourceMap = {
139142
...sourceMap,
143+
// When using the x_react_sources extension field, the first item
144+
// for a given source is reserved for the Hook Map.
140145
x_react_sources: [[encodedHookMap]],
141146
};
142147

packages/react-devtools-extensions/src/parseHookNames/parseHookNames.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,8 +667,15 @@ function extractHookMapFromSourceMap(
667667
): HookMap | null {
668668
let hookMap;
669669
if (sourcemap.hasOwnProperty(REACT_SOURCES_EXTENSION_KEY)) {
670+
// When using the x_react_sources extension field, the first item
671+
// for a given source is reserved for the Hook Map, which is why
672+
// we look up the index at position 0.
670673
hookMap = sourcemap[REACT_SOURCES_EXTENSION_KEY][sourceIndex][0];
671674
} else if (sourcemap.hasOwnProperty(FB_SOURCES_EXTENSION_KEY)) {
675+
// When using the x_fb_sources extension field, the first item
676+
// for a given source is reserved for the Function Map, and the
677+
// Hook Map is added as the second item, which is why we look up
678+
// the index at position 1.
672679
hookMap = sourcemap[FB_SOURCES_EXTENSION_KEY][sourceIndex][1];
673680
}
674681
if (hookMap != null) {

0 commit comments

Comments
 (0)