Skip to content

Commit

Permalink
feat: add guide for using props as a key of query
Browse files Browse the repository at this point in the history
  • Loading branch information
S-sohofi authored Sep 23, 2024
1 parent 9da00d6 commit acddba3
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/framework/vue/guides/query-keys.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,14 @@ function useTodos(todoId) {
```

[//]: # 'Example5'

### If your query function depends on a props value, include it in your query key using computed variable
```js
<script setup>
const props = defineProps([todoId])
const todoIdValue = computed(()=>return props.todoId)
const queryKey = ['todos', todoIdValue]
const result = useQuery(queryKey, () => fetchTodoById(todoIdValue.value))
</script>
```

0 comments on commit acddba3

Please sign in to comment.