robisim74/qwik-speak

Internal server error: Code(20): Calling a 'use*()' method outside component$...

primozs opened this issue · 4 comments

The whole message is:
Internal server error: Code(20): Calling a 'use*()' method outside 'component$(() => { HERE })' is not allowed. 'use*()' methods provide hooks to the 'component$' state and lifecycle, ie 'use' hooks can only be called synchronously within the 'component$' function or another 'use' method. For more information see: https://qwik.builder.io/docs/components/tasks/#use-method-rules

and stack trace points to "placeholder attribute prop"
I am using "qwik-speak": "^0.13.0" but it started in previous versions.

<Input
     // this does not work any more
     placeholder={t('app.enterYourEmail@@Enter your email')}
/>`
`

but this is ok

`const inputPlaceholderMsg = t('app.enterYourEmail@@Enter your email');

<Input
   placeholder={inputPlaceholderMsg}
/>`

See #50

I have read #50
I don't like the dx because you need to think where you are passing this "t" translate$ function.
Could we have useTranslate that would return inline translate without requirement to pass context.

something like
const {t} = useTranslate()

then use t('message') wherever.

Ok this could be done by user also

@primozs Yes, I'm already working on the useTranslate solution - I just need to troubleshoot with Inlining and it will be released soon