reactjs - why react dev tools paint highlights to components in this example - Stack Overflow
//App.tsx
import { A } from "./A";
import { B } from "./B";
function App() {
return (
<>
<div>
<B />
</div>
<A />
</>
);
}
export default App;
//A.tsx
import { useState } from "react";
export const A = () => {
const [count, setCount] = useState(0);
return (
<div onClick={() => setCount((prevCount) => prevCount + 1)}>{count}</div>
);
};
//B.tsx
export const B = () => {
return <div>123</div>
}
In the App.tsx code above, when you click on component A, component B is also highlighted. However, after removing the div that wraps component B, clicking on component A no longer highlights component B. Why does this happen?
I'm studying React's reconciliation and virtual DOM, but I'm having a hard time understanding it.
---
another...
import { A } from "./A";
function App() {
return (
<>
<div>
<A />
<A />
</div>
<div>
<A />
</div>
</>
);
}
export default App;
The above code also shows the highlight in an unusual way.
最新文章
- 隔墙也能认出你:MIT研究出Wi-Fi透视术
- 百度地图打造移动互联网的大世界和微生活
- 谷歌正在复制苹果模式?(图)
- schema - TALLY XML API ISSUE - Stack Overflow
- uart - MH-z19b stop working after 999999 millis (NodeMCU v3 ESP8266 12F) - Stack Overflow
- android - Not receiving events using a BroadcastReceiver - Stack Overflow
- reactjs - how to fetch headers in middleware in Next js - Stack Overflow
- python - Bullets shooting from wrong position after player moved in small "Space Invaders" game - Stack Overfl
- rcpp - C++ AVX2 custom functions (e.g., "exp") not working on Windows (but work on Linux) - Stack Overflow
- java - How to configure asynchronous processors with StepBuilder in Spring batch v5.2 - Stack Overflow
- augmented reality - Applying 2d image to a 3d object in xcode tutorials? - Stack Overflow
- Optional parentheses for C variadic macro (i.e. both function-like and object-like) - Stack Overflow
- python - Galaga game not running due to an empty range - Stack Overflow
- html - CSS "vertical-align: middle" doesn't shrink the height of the parent element of img - Stack Ove
- algorithmic trading - Why is my python script working sometimes but not others? There seems to be a delay for it to work - Stack
- c++ - Member of struct constructed twice in custom constructor? - Stack Overflow
- Conflicting dependencies while installing torch==1.10.0, torchaudio==0.10.0, and torchvision==0.11.0 in my Python environment -