between components
how do I pass the selected _id from one component to another
so far trying this
<>
<p>Welcome {viewer}!!!</p>
<p>
<SelectPodcast podcasts={podcasts} /> <PodcastNumber />
<Episode podcast_id={podcasts[0]["_id"]} episode_number={1} />
</p>
</>
getting this error
Unhandled Runtime Error
TypeError: Cannot read properties of undefined (reading '_id')
Source
app/add_dates/add_dates.tsx (79:41) @ SignedInContent
77 | <p>
78 | <SelectPodcast podcasts={podcasts} /> <PodcastNumber />
> 79 | <Episode podcast_id={podcasts[0]["_id"]} episode_number={1} />
| ^
80 | </p>
81 |
82 | </>
5 Replies
this compiles but gets that runtime error
it works without 79
You'll want to make sure
podcasts[0]
has a value before you render.
cool thanks
If I have a select in another component how do I update the value in this component
I am not storing the selection in convex. so do I need to use useState()
@ballingt to make updates between components, if I am not using a mutation, should I - useState();
@burnstony#1975 can you say more about what you want?
In React, forgetting Convex, yes to store state you should use
useState()
. You can pass the setter as a prop to child components so they can set state in a parent.Got it, wasn’t sure if convex had some different magic
Thanks