Skip to content
This repository has been archived by the owner on Mar 4, 2020. It is now read-only.

feat(Provider): add overwrite prop #1780

Merged
merged 6 commits into from
Aug 12, 2019
Merged

Conversation

layershifter
Copy link
Member

@layershifter layershifter commented Aug 9, 2019

♻️ overwrite prop

This PR adds overwrite prop for Provider component. It allows to reset current context and avoid merging with existing themes. Existing behavior is preserved.

overwrite=false

<Provider theme={themes.teams}> // Teams theme
  <Provider theme={themes.base} /> // Teams + Base theme

overwrite=true

<Provider theme={themes.teams}> // Teams theme
  <Provider overwrite theme={themes.base} /> // Base theme

@@ -177,7 +181,7 @@ class Provider extends React.Component<WithAsProp<ProviderProps>> {
target={target}
{...{ rehydrate: false }}
>
<ThemeProvider theme={outgoingContext}>
<ThemeProvider theme={outgoingContext} overwrite>
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ThemeProvider comes from Fela, we should always use overwrite as Fela has own shallow merging.

https://github.com/robinweser/fela/blob/v10.6.1/packages/fela-bindings/src/ThemeProviderFactory.js

@lucivpav
Copy link
Contributor

lucivpav commented Aug 9, 2019

Let's test this change.

@codecov
Copy link

codecov bot commented Aug 9, 2019

Codecov Report

Merging #1780 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1780      +/-   ##
==========================================
+ Coverage   69.76%   69.77%   +<.01%     
==========================================
  Files         867      867              
  Lines        7353     7354       +1     
  Branches     2158     2136      -22     
==========================================
+ Hits         5130     5131       +1     
  Misses       2215     2215              
  Partials        8        8
Impacted Files Coverage Δ
...ackages/react/src/components/Provider/Provider.tsx 95.45% <100%> (+0.1%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 94feb58...878eef4. Read the comment docs.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants