Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable unstable_batchedUpdates() on event handlers in React

Tags:

reactjs

I am trying to disable unstable_batchedUpdates() in React. I am starting to think it isn't possible. This is what I am trying:

ReactDOM.unstable_batchedUpdates = callback => callback()

I am searching for a solution which will help me avoid wrapping the code in event handlers with a setTimeout():

<div onClick={() => {
  setTimeout(() => {
     setInputVisible(true)

     inputRef.current.focus()
  })
}}>
like image 688
astoilkov Avatar asked Sep 12 '25 09:09

astoilkov


1 Answers

I finally made progress with a conversation I had with Dan Abramov on GitHub. Posting the conversation here for reference: Batching makes it difficult to perform imperative actions like focus.

like image 61
astoilkov Avatar answered Sep 14 '25 22:09

astoilkov