Refactor how we fetch the user profile - #3747
Closed
oliverlloyd wants to merge 18 commits into
Closed
oliverlloyd wants to merge 18 commits into
oliverlloyd wants to merge 18 commits into
Conversation
oliverlloyd
requested review from
DavidLawes,
OllysCoding,
jlieb10,
lucymonie and
nitro-marky
as code owners
December 10, 2021 12:48
|
Size Change: +675 B (0%) Total Size: 3.13 MB
ℹ️ View Unchanged
|
Contributor
Author
oliverlloyd
marked this pull request as draft
December 10, 2021 17:35
Contributor
Author
|
Closing now that we've completed this work via separate PRs |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What does this change?
This PR moves the logic for how we fetch the reader's profile out of
App.tsxand down into the local components that use itWhy?
This is part of a wider effort to remove global state from
App.tsx. See this document for more details on this.Doesn't this mean we will fetch the profile twice?
No. Because we're using SWR, we will cache the first call and any subsequent fetch requests to the same endpoint will be served from this cache.
Why
DiscussionContainer?This PR introduces
DiscussionContainerandDiscussionWhenSignedIn. This is required because you cannot conditionally call a react hook. To get around this - and arguably to separate code concerns better - we have these additional components that manage deciding if the reader is signed in and another to fetch the profile.