infinite loop with dynamically nested components
See original GitHub issueHi, I’ve got a browser-crashing scenario with some nested components where translate is called on an inner and outer component. I guess it’s some weird edge-case with context handling.
I’ve tried to dumb it down quite a bit:
OuterComponent renders MiddleComponent and passes an anonymous Component that renders InnerComponent with some extra parameter.
OuterComponent and InnerComponent are translated.
I’m sorry that this is still so complex, but I couldn’t get this any more simple.
Is this a bug in react-i18next? Is it something in react itself?
import * as React from 'react';
import {translate, Trans} from 'react-i18next';
const InnerComponent = translate()(
({name}: { name: string }) => <Trans>some-test</Trans>
);
const MiddleComponent = ({Component}: { Component: React.ComponentType }) => <div><Component /></div> ;
const OuterComponent = translate()(
class extends React.Component<any> {
render() {
console.log('this loops like crazy...');
return (
<div>
<MiddleComponent Component={() => <InnerComponent name="qwe"/>}/>
</div>
);
}
}
);
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (6 by maintainers)
Top Results From Across the Web
Having to dynamically change the state : how to avoid an ...
It is obvious that right now my code generates an infinite-loop: The component is created and rendered for the first time. During this...
Read more >C++ - Infinite Loops| Nested Loops - YouTube
00:00 Infinite Loops02:56 Nested LoopsTHANKS FOR WATCHING AND DON'T FORGET TO LIKE, COMMENT, SUBSCRIBE, AND HIT THE BELL ICON TO WATCH THE ...
Read more >Loops in Ruby - performing repeated operations on a data ...
Loops and iterators in Ruby are a great way to perform repeated operations on a data set. Step by step tutorial for the...
Read more >For Each...Next Statement - Visual Basic
Syntax; Parts; Simple Example; Nested Loops; Exit For and ... Next statement iterates through all the elements of a List collection.
Read more >Why is it so difficult to modify a deeply nested state in React?
It's not uncommon to see a code like that in React world. All this effort just to update a single to-do item inside...
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

hm…must be some weird timing issue…but honestly no exact idea why
the cache does add resource bundles and cause of that triggers a few times added - as we listen to added and trigger a rerender upon that this might be to much…?!?
could you try setting
bindStoreto false?translate('yourNS', { bindStore: false })(OuterComponent)Oh, nice. I was still at 4.7.0 which didn’t have that option. Had not noticed that this was getting so many updates 😃