This repository has been archived by the owner on Dec 3, 2022. It is now read-only.
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.
useFocusEffect / useIsFocused #43
useFocusEffect / useIsFocused #43
Changes from all commits
3304438
21d754e
ab60ff2
18ced88
049a46c
88b61a7
5044bca
d354567
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.
@slorber If I run setParams in callback, navigation will change and invoke callback again, it will raise a infinite loop
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.
thanks for reporting this.
@satya164 how do you handle those loops in v5? I guess we should fix it the same way in v5 and here
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.
v5 doesn't update
navigation
prop on params update sinceroute
is a separate prop. regarding how to handle it in v4, user needs to add a check manually that params are out of date before trying to update them. they should do it anyways to prevent unnecessary updates to the screen regardless of the loop anyways since we don't do any equality checks likesetState
does.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.
@satya164 I understand your point about preventing useless re-renders/infinite loops.
But if param value has to change, we still don't necessarily want to re-execute useFocusEffect again (at least user should be in control imho)
I mean:
This one should re-execute on userId param change
But this one should rather not re-execute even if any param changes:
So I think it's not correct to make this hook depend on navigation here, as the object is unstable it will tend to produce unwanted effect re-execution. I guess it will even re-execute if the parent re-renders for example.
I've opened another issue: #48