Skip to content

[question]Why does this error(Hooks can only be called inside of the body of a function component) occurs? #223

Closed Answered by liaodalin19903
liaodalin19903 asked this question in Q&A
Discussion options

You must be logged in to vote

Solved it by:

  const greetingQuery = trpcReact.greeting.useQuery({ name: 'Electron' });  // when execute this line it report error

  const clickHandle = () => {

    console.log('clicked')
    const data = greetingQuery.data

    console.log('greeting return data: ', data)

  }

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by liaodalin19903
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants