Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Split RUIProvider into two #583

wants to merge 3 commits into from

Conversation

mbohal
Copy link
Contributor

@mbohal mbohal commented Dec 20, 2024

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.

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.

TranslationsProvider.defaultProps = {
children: null,
translations: defaultTranslations,
Copy link
Contributor

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?

Copy link
Contributor Author

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.

src/providers/globalProps/withGlobalProps.jsx Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants