-
Notifications
You must be signed in to change notification settings - Fork 53
fix(renderComponent): do not throw if context is missing #1837
Conversation
}, emptyTheme) | ||
return acc | ||
}, | ||
{ ...emptyTheme }, |
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.
Clone is required as it will modify the source object. I have two options:
- leave a comment
- use
Object.freeze
onemptyTheme
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.
leave a comment :)
Codecov Report
@@ Coverage Diff @@
## master #1837 +/- ##
==========================================
- Coverage 69.49% 69.49% -0.01%
==========================================
Files 875 875
Lines 7603 7602 -1
Branches 2243 2241 -2
==========================================
- Hits 5284 5283 -1
Misses 2311 2311
Partials 8 8
Continue to review full report at Codecov.
|
@@ -203,7 +195,7 @@ const renderComponent = <P extends {}>( | |||
displayName, | |||
props: stateAndProps, | |||
variables: resolvedVariables, | |||
theme: context.theme, |
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.
context
can be undefined
if there are no wrapping Provider
and it will throw an error
@@ -142,7 +142,7 @@ const resolveStyles = ( | |||
|
|||
const renderComponent = <P extends {}>( | |||
config: RenderConfig<P>, | |||
context: ProviderContextPrepared, | |||
context?: ProviderContextPrepared, |
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.
I marked context
as optional to emphasize that it can be undefined
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.
I understand that this would fix the problem of not throwing when Provider is not defined, but we are still not telling the user, why the Button is not rendered as expected, if there is no Provider :\ It seems like we are silencing the error, instead of explaining it...
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.
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.
Got it, I missed that, thanks for the clarification
Co-Authored-By: Pavel Lučivňák <[email protected]>
…/github.com/stardust-ui/react into fix/render-component-context # Conflicts: # CHANGELOG.md
Fixes #1834.