0
const fetchData = async (key, compId, tmId) => {
    console.log('params: ', { key, compId, tmId });

    let url = `/this-path/comp/${compId}/tm/${tmId}`;
    const result = await axios.get(url);
    return result.data;
};

const fetchOutput = useQuery(['string-key', 231, 1053039], fetchData);

In the example above, we need the fetchData() parameter compId to equal 231, and tmId to equal 1053039. Based on my understanding of react-query, I thought that I would get this. However, instead we get this:

enter image description here

...where the queryKey array is accessable at key.queryKey, however the params compId and tmId are undefined, even though we're using useQuery() as such: useQuery(['string-key', 231, 1053039], fetchData)...

Is there something we're missing here? How can we get these values to serve as parameters for the callback fetchData function?

1 Answer 1

2

enter image description here

this, from the v3 migration guide, answers my question...

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.