Next.js Discord

Discord Forum

How to trigger a user event in a client component without causing the server component rebuild?

Unanswered
Pteromalid wasp posted this in #help-forum
Open in Discord
Pteromalid waspOP
I have the following structure
<ClientComponent1 />
<SeverComponent>
  <ClientComponent2 />
</SeverComponent>


In the ClientComponent1, there is a search bar that filter the data in the ClientComponent2. The SeverComponent is used for fetching data from the sever and push it to the useQuery.

I currently use search param to make the ClientComponent2 receive the ClientComponent1 search terms but it will make the SeverComponent fetch the data from api again.

7 Replies

btw, if im not going to use search query, is there any other way to achieve the same thing?
@Pteromalid wasp btw, if im not going to use search query, is there any other way to achieve the same thing?
<Context>
  <ClientComponent1 />
  <ServerComponent>
    <ClientComponent2 />
  </ServerComponent>
</Context>

both client components read from and write to the context
Pteromalid waspOP
if i have multiple structure like this in one page, which means multiple search bar, do u recommend using context or search query?
it depends on the purpose of those search bars, but 99% of the time i prefer search bars
* 99% of the time I prefer search queries, sorry my brain farted