Skip to content

Commit 86ed0cd

Browse files
author
Brian Vaughn
committed
Added inline comment
1 parent 73db175 commit 86ed0cd

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/react-devtools-shared/src/devtools/views/Components/InspectedElementContext.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,10 @@ export function InspectedElementContextController({children}: Props) {
5656

5757
const refresh = useCacheRefresh();
5858

59-
// Track the paths insepected for the currently selected element.
59+
// Temporarily stores most recently-inspected (hydrated) path.
60+
// The transition that updates this causes the component to re-render and ask the cache->backend for the new path.
61+
// When a path is sent along with an "inspectElement" request,
62+
// the backend knows to send its dehydrated data even if the element hasn't updated since the last request.
6063
const [state, setState] = useState<{|
6164
element: Element | null,
6265
path: Array<number | string> | null,
@@ -97,7 +100,8 @@ export function InspectedElementContextController({children}: Props) {
97100
[setState, state],
98101
);
99102

100-
// Reset path
103+
// Reset path now that we've asked the backend to hydrate it.
104+
// The backend is stateful, so we don't need to remember this path the next time we inspect.
101105
useEffect(() => {
102106
if (state.path !== null) {
103107
setState({

0 commit comments

Comments
 (0)