mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-24 04:33:10 +00:00
Fix broken tabs (#8063)
This commit is contained in:
@@ -398,7 +398,7 @@ Here is a complete example you can play with:
|
||||
}
|
||||
```
|
||||
|
||||
```js
|
||||
```js src/App.js
|
||||
import { useRef, useEffect, useState } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { createMapWidget, addPopupToMapWidget } from './map-widget.js';
|
||||
|
||||
@@ -87,7 +87,7 @@ To do this, you need to render in two passes:
|
||||
|
||||
**All of this needs to happen before the browser repaints the screen.** You don't want the user to see the tooltip moving. Call `useLayoutEffect` to perform the layout measurements before the browser repaints the screen:
|
||||
|
||||
```js
|
||||
```js {5-8}
|
||||
function Tooltip() {
|
||||
const ref = useRef(null);
|
||||
const [tooltipHeight, setTooltipHeight] = useState(0); // You don't know real height yet
|
||||
@@ -187,7 +187,7 @@ export default function ButtonWithTooltip({ tooltipContent, ...rest }) {
|
||||
}
|
||||
```
|
||||
|
||||
```js
|
||||
```js src/Tooltip.js active
|
||||
import { useRef, useLayoutEffect, useState } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import TooltipContainer from './TooltipContainer.js';
|
||||
@@ -337,7 +337,7 @@ export default function ButtonWithTooltip({ tooltipContent, ...rest }) {
|
||||
}
|
||||
```
|
||||
|
||||
```js
|
||||
```js src/Tooltip.js active
|
||||
import { useRef, useLayoutEffect, useState } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import TooltipContainer from './TooltipContainer.js';
|
||||
@@ -484,7 +484,7 @@ export default function ButtonWithTooltip({ tooltipContent, ...rest }) {
|
||||
}
|
||||
```
|
||||
|
||||
```js
|
||||
```js src/Tooltip.js active
|
||||
import { useRef, useEffect, useState } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import TooltipContainer from './TooltipContainer.js';
|
||||
|
||||
@@ -225,7 +225,7 @@ export default function App() {
|
||||
|
||||
```
|
||||
|
||||
```js
|
||||
```js src/TodoList.js active
|
||||
import { useMemo } from 'react';
|
||||
import { filterTodos } from './utils.js'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user