parent
aa6d48b775
commit
2596091167
2 changed files with 33 additions and 1 deletions
@ -0,0 +1,9 @@ |
||||
The `flushSync` function in React is used to flush updates synchronously. It schedules updates to be performed inside a high-priority task, ensuring that the updates are executed immediately and synchronously before returning control to the caller. |
||||
|
||||
```js |
||||
import { flushSync } from 'react-dom'; |
||||
|
||||
flushSync(callback); |
||||
``` |
||||
|
||||
This is useful in situations where you need the DOM to be updated immediately, such as for measurements or to ensure synchronous rendering. However, excessive use of `flushSync` can lead to degraded performance, so it should be used judiciously. |
Loading…
Reference in new issue