I often face the same issue but it is easily solved with a useRef. I usually write a useEagerEffect hook that runs before rendering, but still only runs when the deps array changes.
The part I really agree with, though, is how react's docs (and those of many other libraries) make these sweeping assumptions that nobody could ever possibly need anything outside of their perceived use cases. The blind arrogance you mention really frustrates me!
You're spot-on about the useRef. In fact, in my useConstructor NPM package, I wrote it with useRef, rather than the useState approached illustrated in the article. There was another commenter on this thread that was gracious enough to point me in that direction.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
I often face the same issue but it is easily solved with a useRef. I usually write a useEagerEffect hook that runs before rendering, but still only runs when the deps array changes.
The part I really agree with, though, is how react's docs (and those of many other libraries) make these sweeping assumptions that nobody could ever possibly need anything outside of their perceived use cases. The blind arrogance you mention really frustrates me!
You're spot-on about the
useRef
. In fact, in myuseConstructor
NPM package, I wrote it withuseRef
, rather than theuseState
approached illustrated in the article. There was another commenter on this thread that was gracious enough to point me in that direction.