Invalid hook call error when using withTranslation in class component
See original GitHub issueclass PageTitle extends React.Component {
render() {
const { t } = this.props;
return (
<div>
{t(pageTitle)}
</div>
);
}
}
PageTitle.propTypes = {};
export default withTranslation('common')(PageTitle);
Somehow when i try to use withTranslation
in a class component, it will throw a hooks related error
My package version “next”: “10.0.6” “next-translate”: “^1.0.2”
Issue Analytics
- State:
- Created 3 years ago
- Comments:8
Top Results From Across the Web
Invalid hook call in react. I am using class component
I am using withTranslation() in my react class component at the last line when I am exporting my application. But it is giving...
Read more >Invalid Hook Call Warning - React
You are probably here because you got the following error message: Hooks can only be called inside the body of a function component....
Read more >Invalid hook call with next-i18nnext · Issue #611 - GitHub
Describe the bug Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for...
Read more >Invalid hook call in react. I am using class component-Reactjs
Coding example for the question Invalid hook call in react. I am using ... import { withTranslation } from "react-i18next"; class MyComponent extends...
Read more >Invalid hook call. Hooks can only be called inside of the body ...
Hooks can only be called inside of the body of a function component. in my react native app I have started playing with...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
np. consider using TS as well as move away from class components 😃 maybe you can close this github issue yourself?
Oh, my bad. I missed that part.😓 The error is gone now. I guess I am too used to
react-i18next
’s API 😅