DoneDeal0 / Talkr

Talkr is the lightest i18n provider for React applications. It supports Typescript, provides autocompletion, has 0 dependencies, and is very easy to use.

Home Page:https://talkr-documentation.netlify.app/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

React has detected a change in the order of Hooks

janva255 opened this issue · comments

commented

It happens to me on a conditionally displayed translation for example, when the condition goes from false to true

condition && <Component label={T("translationKey")} />

Screen Shot 2021-04-02 at 12 47 39

What I did to fix it is to declare it before using it but i prefer doing it like I showed before
const translation = T("translationKey")
condition && <Component label={translation} />

Hi, yes your solution is the right way to handle conditional rendering with hooks. Talkr only relies on Context, this is why you must comply to the rule of hooks. It could be fixed, but I'd need to use other packages and this would go against the idea of Talkr: having a super-light i18n solution with 0 dependencies.

commented

@DoneDeal0 Ok, if this is the only way then I can close this issue, thanks

Issue fixed in #17 .