Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
**Feature:** Splash hooks & useInterval #940
**Feature:** Splash hooks & useInterval #940
Changes from 19 commits
2f0a4af
11d0eb9
160e8f1
8b23545
285a5f9
fcba424
26f8582
0b068bd
9205d91
e9740d5
5ff8a28
3fa95de
4de2cd4
d90a337
2110fd3
16bd57e
b065a4e
8c11741
87c471a
7083527
585be4f
32c5741
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The simplest implementation would be
UPD code works only because
useEffect
will be triggered on each render (which is wrong)if we would add delay, it would brake. Example of the bug
count will change from 0 to 1 only once (because
count
is locally bound to function passed touseInterval
), butconsole.log(1);
will be called many timesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@stereobooster ,Dan wrote a nice piece on this.
Simple Implementation works for simple cases ( and how its currently being used in Splash)
But this version is more scalable/reusable ...
Where useRef comes into play...
For Example, this allows us to change the delay or callback between renders without resetting the time
But if you want be to change to simple version, i will do that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concern is that the code should be clear, so people after us would be able to read it easily and change it if they want to. It takes quite some iterations to understand what happens here. After reading Dan's article this all start to make sense, but before it seemed over-engineered. So adding link to the Dan's article and maybe some more comments would help
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. @JoshRosenstein please add some documentation if you wish to keep the component the way it is. ❤️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JoshRosenstein have you seen these comments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mpotomin - It was my understanding the "simplest implementation" version breaks, and should keep the current useInterval as is, and i added additional comments since, Did i miss something ? Or just forgot to resolve?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You just forgot to acknowledge. Thanks for responding, @JoshRosenstein! @stereobooster is that okay with you?