You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What problem do you want to solve?
Cut out the useTranslationAppDir logic from the useTranslation hook in app directory RSC, and put it in another exported regular function (e.g import t from "next-translate/appdir").
React hooks aren't allowed in RSC, so it's misleading having this hook just magically work entirely different (not using state or React hooks even) when in app directory environment.
At first of course I thought that the hook shouldn't work in my RSC, but it does. It's not intuitive and developers shouldn't need to read the source code to get an idea what the hook actually does.
What do you think is the correct solution to this problem?
If I was in charge, I would keep the useTranslation hook as is, and split out the app directory logic into a custom function, because there's no reason for that logic to be in a hook. It's stateless and has nothing to do with React, it's just using a bunch of globals and other internal variables.
Are you willing to submit a pull request to implement this change?
If you don't feel like it, I could give it a go.
The text was updated successfully, but these errors were encountered:
I prefer to return the t function and also the lang instead of only the t function, also because the t function depends on the language. But at least now is not more a hook to work fine in RSC
I prefer to return the t function and also the lang instead of only the t function, also because the t function depends on the language. But at least now is not more a hook to work fine in RSC
I agree, that'd be better than my given example.
Thanks for the quick response and improvement, can't wait to update and try the new helper out!
What version of this package are you using?
2.0.5
What problem do you want to solve?
Cut out the useTranslationAppDir logic from the useTranslation hook in app directory RSC, and put it in another exported regular function (e.g
import t from "next-translate/appdir
").React hooks aren't allowed in RSC, so it's misleading having this hook just magically work entirely different (not using state or React hooks even) when in app directory environment.
At first of course I thought that the hook shouldn't work in my RSC, but it does. It's not intuitive and developers shouldn't need to read the source code to get an idea what the hook actually does.
What do you think is the correct solution to this problem?
If I was in charge, I would keep the useTranslation hook as is, and split out the app directory logic into a custom function, because there's no reason for that logic to be in a hook. It's stateless and has nothing to do with React, it's just using a bunch of globals and other internal variables.
Are you willing to submit a pull request to implement this change?
If you don't feel like it, I could give it a go.
The text was updated successfully, but these errors were encountered: