Skip to content
Advertisement

React – Invalid hook call when calling useTranslation for react-i18next

I’m new to React Native and I’m trying to add translation in my navigation. In any other page it goes fine but not in my navigation.

My i18n.js

JavaScript

My StackNavigators.js

JavaScript

What I’m trying to do is to add translation in BottomTabBar as title of each BottomNavigationTab and when I add const { t, i18n } = useTranslation(); I get Invalid hook call and I’m not sure what would the correct place/way be.

Appreciate any help and thanks in advance!

Advertisement

Answer

You cannot call a hook outside of a React component or hook (see Rules of Hooks). Move this line const { t, i18n } = useTranslation(); inside BottomTabBar component. Like so:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement