MCPcopy Index your code
hub / github.com/TanStack/query / ToggleValueButton

Function ToggleValueButton

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

Source from the content-addressed store, hash-verified

204}
205
206const ToggleValueButton = (props: {
207 dataPath: Array<string>
208 activeQuery: Query
209 value: boolean
210}) => {
211 const theme = useTheme()
212 const css = useQueryDevtoolsContext().shadowDOMTarget
213 ? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
214 : goober.css
215 const styles = createMemo(() => {
216 return theme() === 'dark' ? darkStyles(css) : lightStyles(css)
217 })
218 const queryClient = useQueryDevtoolsContext().client
219
220 return (
221 <button
222 class={cx(
223 styles().actionButton,
224 css`
225 width: ${tokens.size[3.5]};
226 height: ${tokens.size[3.5]};
227 `,
228 )}
229 title={'Toggle value'}
230 aria-label={'Toggle value'}
231 onClick={() => {
232 const oldData = props.activeQuery.state.data
233 const newData = updateNestedDataByPath(
234 oldData,
235 props.dataPath,
236 !props.value,
237 )
238 queryClient.setQueryData(props.activeQuery.queryKey, newData)
239 }}
240 >
241 <Check theme={theme()} checked={props.value} />
242 </button>
243 )
244}
245
246type ExplorerProps = {
247 editable?: boolean

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

Used in the wild real call sites across dependent graphs

searching dependent graphs…