I have component A where I want to set variable using useQuery instead of useState
function A() {
let varA= useQuery(['objA'], '');
then inside A I have dropDown list where I set varA using callback function
const handleDropDownSelect = (e) => {
varA= e.value;
}
Till this moment everything works fine.
Also the whole app is enclosed in <QueryClientProvider client={queryClient}>
Now I have component B.jsx
function B() {
Where I want to use that varA. I've tried this thing but it won' work.
const queryClient = useQueryClient();
const varA= queryClient.getQueryData('objA');
I get error
queryCache.ts:171 Uncaught TypeError: Cannot create property 'exact' on string 'objA'
How can I fix this problem ?