mirror of
https://github.com/reactjs/react.dev.git
synced 2026-02-24 04:33:10 +00:00
Fix flushSync.md grammar (#6282)
This commit is contained in:
@@ -89,14 +89,14 @@ import { flushSync } from 'react-dom';
|
||||
|
||||
export default function PrintApp() {
|
||||
const [isPrinting, setIsPrinting] = useState(false);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
function handleBeforePrint() {
|
||||
flushSync(() => {
|
||||
setIsPrinting(true);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
function handleAfterPrint() {
|
||||
setIsPrinting(false);
|
||||
}
|
||||
@@ -108,7 +108,7 @@ export default function PrintApp() {
|
||||
window.removeEventListener('afterprint', handleAfterPrint);
|
||||
}
|
||||
}, []);
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<h1>isPrinting: {isPrinting ? 'yes' : 'no'}</h1>
|
||||
@@ -122,7 +122,7 @@ export default function PrintApp() {
|
||||
|
||||
</Sandpack>
|
||||
|
||||
Without `flushSync`, when the print dialog will display `isPrinting` as "no". This is because React batches the updates asynchronously and the print dialog is displayed before the state is updated.
|
||||
Without `flushSync`, the print dialog will display `isPrinting` as "no". This is because React batches the updates asynchronously and the print dialog is displayed before the state is updated.
|
||||
|
||||
<Pitfall>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user