-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split RUIProvider
into two
#583
base: master
Are you sure you want to change the base?
Conversation
This commit splits `RUIProvider` into `TranslationsProvider` and `GlobalPropsProvider`. The reasons fo this change are: * Improve performance by reducing rerenders in cases when the context value change dynamically. * Make code more readable by splitting isolated functionality into isolated prividers.
src/providers/translations/__tests__/TranslationsProvider.test.jsx
Outdated
Show resolved
Hide resolved
|
||
TranslationsProvider.defaultProps = { | ||
children: null, | ||
translations: defaultTranslations, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is weird that defaultTranslations
is used in TranslationsContext
as default value. Then again here in TranslationsProvider.defaultProps
. It was before so we might leave as it is, but it looks weird now.
I am just curious that || {}
disappeared from mergeDeep(context?.translations || {}, translations)
. I can't remember the purpose, but are we sure it can be removed from here and GlobalPropsProvider.jsx
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is weird that defaultTranslations is used in TranslationsContext as default value.
Default value is now {}
but are we sure it can be removed from here and GlobalPropsProvider.jsx
Before the default value was null
. I changed it to {}
so now we can ommit the || {}
part. I can see no issue with it.
This commit splits
RUIProvider
intoTranslationsProvider
andGlobalPropsProvider
.The reasons fo this change are:
Improve performance by reducing rerenders in cases when the context value change dynamically.
Make code more readable by splitting isolated functionality into isolated prividers.