MCPcopy Create free account
hub / github.com/TanStack/query / DeleteItemButton

Function DeleteItemButton

packages/query-devtools/src/Explorer.tsx:195–222  ·  view source on GitHub ↗
(props: {
  dataPath: Array<string>
  activeQuery: Query
})

Source from the content-addressed store, hash-verified

193}
194
195const DeleteItemButton = (props: {
196 dataPath: Array<string>
197 activeQuery: Query
198}) => {
199 const theme = useTheme()
200 const css = useQueryDevtoolsContext().shadowDOMTarget
201 ? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
202 : goober.css
203 const styles = createMemo(() => {
204 return theme() === 'dark' ? darkStyles(css) : lightStyles(css)
205 })
206 const queryClient = useQueryDevtoolsContext().client
207
208 return (
209 <button
210 class={cx(styles().actionButton)}
211 title={'Delete item'}
212 aria-label={'Delete item'}
213 onClick={() => {
214 const oldData = props.activeQuery.state.data
215 const newData = deleteNestedDataByPath(oldData, props.dataPath)
216 queryClient.setQueryData(props.activeQuery.queryKey, newData)
217 }}
218 >
219 <Trash />
220 </button>
221 )
222}
223
224const ToggleValueButton = (props: {
225 dataPath: Array<string>

Callers

nothing calls this directly

Calls 6

useThemeFunction · 0.90
useQueryDevtoolsContextFunction · 0.90
deleteNestedDataByPathFunction · 0.90
darkStylesFunction · 0.70
lightStylesFunction · 0.70
setQueryDataMethod · 0.45

Tested by

no test coverage detected