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

Function ClearArrayButton

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

Source from the content-addressed store, hash-verified

164}
165
166const ClearArrayButton = (props: {
167 dataPath: Array<string>
168 activeQuery: Query
169}) => {
170 const theme = useTheme()
171 const css = useQueryDevtoolsContext().shadowDOMTarget
172 ? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
173 : goober.css
174 const styles = createMemo(() => {
175 return theme() === 'dark' ? darkStyles(css) : lightStyles(css)
176 })
177 const queryClient = useQueryDevtoolsContext().client
178
179 return (
180 <button
181 class={styles().actionButton}
182 title={'Remove all items'}
183 aria-label={'Remove all items'}
184 onClick={() => {
185 const oldData = props.activeQuery.state.data
186 const newData = updateNestedDataByPath(oldData, props.dataPath, [])
187 queryClient.setQueryData(props.activeQuery.queryKey, newData)
188 }}
189 >
190 <List />
191 </button>
192 )
193}
194
195const DeleteItemButton = (props: {
196 dataPath: Array<string>

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected