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

Function ClearArrayButton

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

Source from the content-addressed store, hash-verified

154}
155
156const ClearArrayButton = (props: {
157 dataPath: Array<string>
158 activeQuery: Query
159}) => {
160 const theme = useTheme()
161 const css = useQueryDevtoolsContext().shadowDOMTarget
162 ? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
163 : goober.css
164 const styles = createMemo(() => {
165 return theme() === 'dark' ? darkStyles(css) : lightStyles(css)
166 })
167 const queryClient = useQueryDevtoolsContext().client
168
169 return (
170 <button
171 class={styles().actionButton}
172 title={'Remove all items'}
173 aria-label={'Remove all items'}
174 onClick={() => {
175 const oldData = props.activeQuery.state.data
176 const newData = updateNestedDataByPath(oldData, props.dataPath, [])
177 queryClient.setQueryData(props.activeQuery.queryKey, newData)
178 }}
179 >
180 <List />
181 </button>
182 )
183}
184
185const DeleteItemButton = (props: {
186 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