Closed badris101 closed 4 years ago
of course hooks can only be called inside the body of a function component
, so are you using hooks outside function component? that does nothing to this lib
no i m calling hooks corectly inside the body of function i think the problem similer to issue
this is my code that expose the error:
`import React, { useState } from 'react' import translate from 'next-i18n-helper/dist/translate' import { i18nHelper } from 'components/i18n'
const translateNS = ['index']
const Header = () => { const [lang, setLang] = useState(i18nHelper.getCurrentLanguage())
const handleLang = (e) => {
setLang(e.target.value)
i18nHelper.setCurrentLanguage(e.target.value)
}
return (
<select value={lang} onChange={handleLang}>
<option value="en">English</option>
<option value="fr">Frensh</option>
</select>
)
}
const TranslatedHeader = translate(translateNS)(Header) TranslatedHeader.translateNS = translateNS
export default TranslatedHeader `
I tried your code in my basic example with only changing import, it worked fine, so it's not problem of this lib, can you merge your logic to the examples, https://github.com/postor/next-i18n-helper/tree/master/examples
hooks can only be called inside the body of a function component
I had multiple instances of React ├┬ next-i18n-helper@1.0.27 └── react@16.13.1 └── react@16.12.0