Comments (7)
@joshswan I've tried to debug the problem but still haven't found the cause yet. Hope you can help.
from react-native-globalize.
This is related to this React issue. Basically your HoC is implementing a shouldComponentUpdate
that is only looking at it's own props and not considering the fact that the context changes affect children down the line. It's difficult to say what a good solution would be at this time, though I can say that simply pulling in the locale in the connect
of the HoC solves the issue since it then knows that something changed and re-renders. Obviously a total hack but at least it pins down the issue.
from react-native-globalize.
@joshswan Thank you, it works. I thought I had to pass context properly somehow between HoC. Now simply adding locale from reducer in connect
map state
solves the problem.
from react-native-globalize.
@joshswan Hi, could you take a look again in the demo repo? (I've add more example code)
I've encountered the same error when globalize Components is nested inside a Navigator from react-navigation
. Setting new prop doesn't make the component re-render in anyway.
I don't think it's the same issue as with context
and shouldComponentUpdate
above, since new locale is passed to Component correctly when new prop is added and Component is not nested inside Navigator.
from react-native-globalize.
I can finally solve the issue with Navigators by passing outer globalize context in screenProps
, then provide it back for screens inside Navigators. This is due to react-navigation
has their own context, which is navigation
, and it causes issue somehow with other context. Logging inside Formatted
components I can see that they rerender when locale
is changed from outside (Redux), but some how globalize
context & its locale
stays the same value
from react-native-globalize.
Unfortunately I don't have much experience with react-navigation
. It seems weird that changes in context
would not be propagated down. Frankly, in your situation, I'd probably just implement a small HoC that injects appropriate values from state where necessary and maybe tweaks the shouldComponentUpdate
method to look at context. Then you can just wrap components with something like withGlobalize(MyComponent)
to minimize the repetition and make sure things work as expected.
from react-native-globalize.
Yes, that what I've done to solve the issue. Thank you for the help.
from react-native-globalize.
Related Issues (20)
- Support for getting the currency symbol directly. HOT 6
- Is there a way this library can detect the locale automatically? HOT 2
- Undefinided is not an object <FormattedCurrency> HOT 1
- gulp cldr error HOT 1
- pt-BR is missing HOT 1
- Typescript support HOT 4
- postinstall step failing on CircleCI HOT 2
- typing of `useGlobalize().formatMessage` HOT 1
- [Proposal] useGlobalize generic type HOT 7
- getCurrencySymbol() with GlobalizeProvider throwing TypeError HOT 4
- How to use useGlobalize with class component HOT 4
- formatCurrency always return Error value must be anumber HOT 5
- Fallback locale in case formatMessage failure HOT 3
- Fallback locale does not fork HOT 4
- Customizing Formatted Currency Component HOT 4
- [RNGlobalize] Error processing message welcome HOT 1
- Translate functions strings HOT 1
- Access functions outside components HOT 2
- On demand loading of locales in a web app HOT 2
- Unable to resolve "../../../../../globalize" HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-globalize.