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

Function ToggleValueButton

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

Source from the content-addressed store, hash-verified

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