I haven't looked at the source code so I'm not sure. Components that are children of ReachAlert should not have their context values changed by <ReachAlert>.
Additional context
I discovered this bug when using react-intl's FormattedMessage component with ReachAlert:
CodeSandbox Template
[React Intl] Could not find required `intl` object. <IntlProvider> needs to exist in the component ancestry.
Clearly, IntlProvider is set up correctly in the component tree so that is not the problem. When I remove ReachAlert the error is gone! The simpler case seems to reveal what might be happening: the context values under ReachAlert are somehow unset.
Your environment
(This is for my local machine where I can reproduce, clearly CodeSandbox uses different versions and it's still reproducible on there)
The reason for this is because we are creating a new React root for our mirror. This causes some other problems as well, so I'm looking to fix this as time allows.
🐛 Bug report
Current Behavior
When a component that uses context is a child of
ReachAlert
, then the context value is called a second time withundefined
.Console output:
Without
ReachAlert
wrappingComponentThatUsesContext
, the console output is simply:Expected behavior
Context should not be set to
undefined
.Reproducible example
CodeSandbox Template
Suggested solution(s)
I haven't looked at the source code so I'm not sure. Components that are children of
ReachAlert
should not have their context values changed by<ReachAlert>
.Additional context
I discovered this bug when using
react-intl
'sFormattedMessage
component withReachAlert
: CodeSandbox TemplateWith that setup, I get the following error:
Clearly,
IntlProvider
is set up correctly in the component tree so that is not the problem. When I removeReachAlert
the error is gone! The simpler case seems to reveal what might be happening: the context values underReachAlert
are somehow unset.Your environment
(This is for my local machine where I can reproduce, clearly CodeSandbox uses different versions and it's still reproducible on there)