Twitter | Search | |
This is the legacy version of twitter.com. We will be shutting it down on 15 December 2020. Please switch to a supported browser or device. You can see a list of supported browsers in our Help Center.
Sagiv Ben Giat
Human | Writing my thoughts in
1,081
Tweets
79
Following
134
Followers
Tweets
Sagiv Ben Giat Nov 25
Replying to @benmvp
What if the types where a separate package that was consumed in both repos? 🤔
Reply Retweet Like
Sagiv Ben Giat Nov 14
Replying to @ZeeCoder
BTW, if you are curious about this and want to play with it, i created a repo example. Feel free to DM me to get the link (i think your DM's are closed)
Reply Retweet Like
Sagiv Ben Giat Nov 14
My thoughts exactly, that's why im thinking its related to SSR (gatsby is SSR by default right?). I'm trying to reproduce this behavior without my library with a more simple and concise example, its hard though 😬
Reply Retweet Like
Sagiv Ben Giat Nov 14
Thanks, I'm not seeing an error/warning, its just refresh the page constantly. It only happens with gatsby.
Reply Retweet Like
Sagiv Ben Giat Nov 13
Have you tested it with server side rendering? (For example gatsby). I had an issue yesterday where gatsby got infinite refresh, the only solution was to use rAF for the listeners (still trying to figure out why it solved the issue).
Reply Retweet Like
Sagiv Ben Giat Oct 25
Replying to @ryanflorence
If you return isCopy and setCopy instead of jsx that could have been a nice hook isn't it?
Reply Retweet Like
Sagiv Ben Giat Oct 11
BTW, the name useRef give us a hint. We are not creating a ref, we just *use* it. It was created for us by someone else outside our context. Imagine that it stored on the window or maybe even passed as an argument. Mutating it will be crystal clear that this is a side effect.
Reply Retweet Like
Sagiv Ben Giat Oct 11
As i see it, Comp is a "stateful" function once you useRef, ref is shard between calls, each call has its own context. If you change it in one context, you affect the other. Maybe the fact that we have 2 branches hidden from us, creating or using the previous ref, throw us off
Reply Retweet Like
Sagiv Ben Giat Oct 10
Yeah i always fight myself with this. Everytime i hot an empty array, it feels like cheating 😅
Reply Retweet Like
Sagiv Ben Giat Oct 10
Forgot the link 🙃
Reply Retweet Like
Sagiv Ben Giat Oct 10
From useReducer docs: Note React guarantees that dispatch function identity is stable and won’t change on re-renders. This is why it’s safe to omit from the useEffect or useCallback dependency list.
Reply Retweet Like
Sagiv Ben Giat Oct 10
Are you sure you need dispatch listed as dependency?
Reply Retweet Like
Sagiv Ben Giat Oct 10
Shouldn't you return ref instead of ref.current?
Reply Retweet Like
Sagiv Ben Giat Oct 7
I would love it if useEffect would give this info out of the box
Reply Retweet Like
Sagiv Ben Giat Sep 27
This is a great game to learn some Great job !
Reply Retweet Like
Sagiv Ben Giat Sep 26
Replying to @dan_abramov
Why did i read it: Re-rendering LOTR makes me feel so good... 🤦🏻‍♂️
Reply Retweet Like
Sagiv Ben Giat Sep 10
Replying to @rwieruch
With hooks you get a native built-in way to share logic. With classes you need to use patterns which have some major pitfalls.
Reply Retweet Like
Sagiv Ben Giat Sep 5
Replying to @rauschma
I revisit this old post of mine and i'm still not sure about this example. I thought you might be able to help here :)
Reply Retweet Like
Sagiv Ben Giat Aug 30
Replying to @jordwalke
If only someone would create a declarative way to manage a state and DOM manipulation would be done for you...
Reply Retweet Like
Sagiv Ben Giat Aug 28
Replying to @tjcrowder
Reply Retweet Like