-
Notifications
You must be signed in to change notification settings - Fork 1
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
[search] Link search results to story screen #37
Conversation
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.
great stuff!
scrollRef.current?.scrollTo({ x: 0, y: 0 }); | ||
}; | ||
|
||
useEffect(() => { |
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.
showing a loading spinner before displaying story works on my end!
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.
i added an empty dependency array to the useEffect or else I saw an infinite loop of calls to fetchAllStoryPreviews
and I think adding the dependency array fits in with what you're desired behavior is.
@@ -77,7 +74,12 @@ function SearchScreen() { | |||
image={item.featured_media} | |||
authorImage={item.author_image} | |||
tags={item.genre_medium} | |||
pressFunction={() => null} | |||
pressFunction={() => | |||
router.push({ |
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.
onPress function works on my end for each of the story cards and the story pages display the correct info!
src/app/(tabs)/story/index.tsx
Outdated
|
||
function StoryScreen() { | ||
const [isLoading, setLoading] = useState(true); | ||
const scrollRef = React.useRef<any>(null); | ||
const [story, setStory] = useState<any>(); | ||
const [story, setStory] = useState<Story>(); |
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.
one workaround to all the null checks is changing the initial value of the story to be like this: useState({} as Story). You can then remove the ? and ! that are being used without warnings I believe
useEffect(() => { | ||
setLoading(true); | ||
(async () => { | ||
const storyResponse = await fetchStory(parseInt(storyId as string, 10)); |
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.
another workaround i can think of, is that you can check if the storyResponse that is returned is null, and if so you just display "No story found" in large letters in the center of the screen. theoretically, a user should never see this because the story will exist b/c it had to have for us to get to this screen, but it will at least stop the compiler warnings
b351006
to
8170f9b
Compare
What's new in this PR
jsonb
instead oftext
Relevant Links
N/A
Notion Sprint Task
N/A
Online sources
Related PRs
How to review
story
useState can be null, which means that when I'm trying to render parts of it I'm doing a lot of null checking or non-null assertion. Just want to make sure this is ok or use a better method if one existsNext steps
N/A
Tests Performed, Edge Cases
N/A
Screenshots
screen-20231106-194507.2.mp4
CC: @akshaynthakur