#Does it make sense to fetch data in a client component at all?

4 messages · Page 1 of 1 (latest)

tight helm
#

Hey all, I am currently building out a carousel component. Works great with everything as RSC, but now I want to add the ability for a carousel item (image) to be clicked and then open in a modal.

Right now, I am getting a list of photos via the Google Places API. It returns an object that contains photos, with a "name" property that is then used as a parameter in another Google endpoint that then returns the actual URL. Right now, that fetch for the image URL is inside the carousel component (pass in the photos, then for each carousel item that's rendered, fetch the URL and apply to <Image /> component.

Obviously in order to use event listeners my carousel component needs to be a client component, which is fine. But then I run into the issue of needing to fetch the individual images inside of a useEffect, which feels dirty. Is this an anti-pattern, or just a side effect sometimes of wanting to use client components?

ashen garnetBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

tulip heart
#

Hmmm its a good question, I like it. Can you supply us with the code? There might be some.... ways around it lol

#

You could apply a invisible mask to the server component that is a client component that handles the modal popup.