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

Function ToggleValueButton

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

Source from the content-addressed store, hash-verified

186}
187
188const ToggleValueButton = (props: {
189 dataPath: Array<string>
190 activeQuery: Query
191 value: boolean
192}) => {
193 const theme = useTheme()
194 const themed = createThemed(theme)
195 const queryClient = useQueryDevtoolsContext().client
196
197 return (
198 <button
199 class={`${themed('tsqd-style-explorer-action-button')} tsqd-style-explorer-toggle-button`}
200 title={'Toggle value'}
201 aria-label={'Toggle value'}
202 aria-pressed={props.value}
203 onClick={() => {
204 const oldData = props.activeQuery.state.data
205 const newData = updateNestedDataByPath(
206 oldData,
207 props.dataPath,
208 !props.value,
209 )
210 queryClient.setQueryData(props.activeQuery.queryKey, newData)
211 }}
212 >
213 <Check theme={theme()} checked={props.value} />
214 </button>
215 )
216}
217
218type ExplorerProps = {
219 editable?: boolean

Callers

nothing calls this directly

Calls 5

useThemeFunction · 0.90
createThemedFunction · 0.90
useQueryDevtoolsContextFunction · 0.90
updateNestedDataByPathFunction · 0.90
setQueryDataMethod · 0.45

Tested by

no test coverage detected