Skip to content

Commit 1e301d0

Browse files
committed
refactor: remove default path slicing
1 parent 652cdfa commit 1e301d0

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

packages/react-devtools-shared/src/backend/renderer.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2730,11 +2730,6 @@ export function attach(
27302730
}
27312731

27322732
function setInContext(id: number, path: Array<string | number>, value: any) {
2733-
// To simplify hydration and display of primative context values (e.g. number, string)
2734-
// the inspectElement() method wraps context in a {value: ...} object.
2735-
// We need to remove the first part of the path (the "value") before continuing.
2736-
path = path.slice(1);
2737-
27382733
const fiber = findCurrentFiberUsingSlowPathById(id);
27392734
if (fiber !== null) {
27402735
const typeSymbol = getTypeSymbol(fiber.type);
@@ -2749,10 +2744,14 @@ export function attach(
27492744
// if the edited context value was the default value of the context
27502745
// there is no Context.Provider above the consumer fiber
27512746
if (providerFiber !== null && typeof overrideProps === 'function') {
2752-
const providerPath = ['value', ...path];
2753-
overrideProps(providerFiber, providerPath, value);
2747+
overrideProps(providerFiber, path, value);
27542748
}
27552749
} else {
2750+
// To simplify hydration and display of primative context values (e.g. number, string)
2751+
// the inspectElement() method wraps context in a {value: ...} object.
2752+
// We need to remove the first part of the path (the "value") before continuing.
2753+
path = path.slice(1);
2754+
27562755
const instance = fiber.stateNode;
27572756
if (path.length === 0) {
27582757
// Simple context value

0 commit comments

Comments
 (0)