D
D
Deniel2021-11-26 23:07:58
React
Deniel, 2021-11-26 23:07:58

Hooks in class components?

How do I use the useQuery (from GraphQL) or useDispatch (react-redux) hooks in class components
PS Unfortunately, there is no way to switch to a functional component.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexandroppolus, 2021-11-26
@Denbo

Unfortunately, there is no way to switch to a functional component.
legacy project with old react version less than 16, "touch it, fall apart"?
dispatch is passed to the props of the component if the second parameter is not given to the connect function.
and in GraphQL there is probably some kind of analogue to create all the things that useQuery creates (I haven’t seen the dock, I can’t say)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question