Closed IvanBoho closed 4 years ago
thinkered around a bit, this is especially noticable when using preact-router as those load async so have inner updates
but also reproducable with any updating component outside of that
when initially rendering the intl
context is correct (using the preact dev tools to test easier)
after an update this no longer works however and intl goes blank
when checking the provider itself that has it's props intact
other non updated components their context does remain intact, not found the oldest version this was introduced in but it seems to be a change in preact itself that did this since this worked fine on 2.0.0-preactx.2 for months in my dev environment
any chance anyone can take a look at this as it makes preact-i18n completely useless?
@AEnterprise, we would welcome a PR to fix this issue.
@billneff79 i'd love to help fix it but sadly i have no clue how, i can't reliably reproduce it outside my project in a new project and i have no clue how any of this context stuff works or is parsed around to go looking for it deeper
I haven't been able to reproduce this, but if someone could pick up where I left off it would be very helpful in fixing this issue if it still exists:
I've managed to reproduce this now, it seems that loading the dictionary asynchronously causes an issue. When the IntlProvider
has props of definition={undefined}
on it's first render, the stale value will eventually overwrite the new value after a child component calls setState
.
Reproduction: https://jsfiddle.net/k8e3fm0n/
Workaround: Add a key={definition}
prop to your IntlProvider
.
Internally, the child component ends up with a condition of component.context !== component._globalContext
which may imply an issue in the diff algorithm for Preact but I'm still investigating.
I'm not sure if there is anything to be done here so I'll follow up in either preactjs/preact or synacor/preact-context-provider.
Fixed by a451350 and released in 2.1.1-preactx
.
Reproduction fixed: https://jsfiddle.net/xyL04bzm/1/
Hello, I have problems with the latest version of preact:
App.tsx
Dom event inside login component:
After state is updated, all translations disappear. The same thing occures in any component. Downgrade helped me.