Skip to content
Discussion options

You must be logged in to vote

with some adjustments started to work perfectly, you could avoid passing params in the query from the tab (since it creates different subscriptions , since post has another key),

you can simple react to the selectedUser

here my example:

queries.ts

import { useSnapshot } from 'valtio'
import { selectedUserIdStore, setSelectedUserId } from './store'

...

const fetchPosts: any = async (queryCtx) => {
  const {
    queryKey: [_key, { selectedUserId } = { selectedUserId: null }],
  } = queryCtx

  // All posts, otherwise get posts filtered by a user id
  const url =
  selectedUserId === null ? POSTS_BASE_URL : `${POSTS_BASE_URL}?userId=${selectedUserId}`

  const res = await (await fetch(url)).

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ernes-to
Comment options

Answer selected by ernes-to
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants