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

Function ToggleValueButton

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

Source from the content-addressed store, hash-verified

222}
223
224const ToggleValueButton = (props: {
225 dataPath: Array<string>
226 activeQuery: Query
227 value: boolean
228}) => {
229 const theme = useTheme()
230 const css = useQueryDevtoolsContext().shadowDOMTarget
231 ? goober.css.bind({ target: useQueryDevtoolsContext().shadowDOMTarget })
232 : goober.css
233 const styles = createMemo(() => {
234 return theme() === 'dark' ? darkStyles(css) : lightStyles(css)
235 })
236 const queryClient = useQueryDevtoolsContext().client
237
238 return (
239 <button
240 class={cx(
241 styles().actionButton,
242 css`
243 width: ${tokens.size[3.5]};
244 height: ${tokens.size[3.5]};
245 `,
246 )}
247 title={'Toggle value'}
248 aria-label={'Toggle value'}
249 aria-pressed={props.value}
250 onClick={() => {
251 const oldData = props.activeQuery.state.data
252 const newData = updateNestedDataByPath(
253 oldData,
254 props.dataPath,
255 !props.value,
256 )
257 queryClient.setQueryData(props.activeQuery.queryKey, newData)
258 }}
259 >
260 <Check theme={theme()} checked={props.value} />
261 </button>
262 )
263}
264
265type ExplorerProps = {
266 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