Translate returning invalid value
See original GitHub issueAfter updating to the latest version and switching to <Translate>
from localize()
, the following error logs to the console and the app doesn’t render at all:
Invariant Violation: Translate.render(): A valid React element (or null) must be returned.
It happens when using <Translate>
with the id
property, but if I supply it a render prop function, everything works well. The code is pretty simple:
const Introduction = () => {
return (
<section className={style.Introduction}>
<article className={style.About}>
<Translate id="introduction" />
</article>
</section>
);
};
export default Introduction;
Issue Analytics
- State:
- Created 5 years ago
- Comments:19 (10 by maintainers)
Top Results From Across the Web
Invalid value (400) using google translate api - Stack Overflow
This error is encounterd when the target language code is invalid. By invalid means its not in the list of languages supported by...
Read more >The method 'Translate' has an invalid value for pa...
Translate failed Hi guys, I've been trying to figure out how to fix this error. When I test it on my desktop this...
Read more >invalid value - Spanish translation - Linguee
Many translated example sentences containing "invalid value" – Spanish-English dictionary and search engine for Spanish translations.
Read more >TranslateText - Amazon Translate API Reference
If you specify auto , you must send the TranslateText request in a region that supports Amazon Comprehend. Otherwise, the request returns an...
Read more >SQLJ Error Messages - Oracle Help Center
Cause: The Oracle customizer translated a SQL operation into an ... Cause: User tries to retrieve a return value from a stored procedure...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Great! I’m glad I was able to help.
I have confirmed that the issue is due to React 15 not supporting fragments and strings.
This was never an issue with the original translate function because that was always used in an expression, and it was ok to use text fragments not wrapped in elements. Where as the new Translate component will require wrapping text elements to render in react v15.
I’m most likely going to update the
package.json
peerDependency for react to16.x.x
, and then update the docs to include the workarounds if they want to use<Translate />
in older versions of React.