You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
SitecoreContext class provide sitecore context via <SitecoreContextReactContext.Provider value={this.contextFactory}> but as suggested in samples implementation is Singleton, default React's Object.is() comparison is not working when SitecoreContextFactory.setSitecoreContext is called and Provider's children are not rerendered.
Expected behavior
All consumers be updated if context value is modified
This has to update headline property's value that should effect our page's tittle. But it does not.
However if you change <SitecoreContextReactContext.Provider value={this.contextFactory}> to <SitecoreContextReactContext.Provider value={Object.assign( Object.create( Object.getPrototypeOf(this.contextFactory)), this.contextFactory)}> it will work fine.
Possible Fix
We have to use React best practice and pass simple objects to Provider value, like this.contextFactory.context
Your Environment
JSS Version: 13.0.0
The text was updated successfully, but these errors were encountered:
Description
SitecoreContext
class provide sitecore context via<SitecoreContextReactContext.Provider value={this.contextFactory}>
but as suggested in samples implementation is Singleton, default React's Object.is() comparison is not working whenSitecoreContextFactory.setSitecoreContext
is called and Provider's children are not rerendered.Expected behavior
All consumers be updated if context value is modified
Steps To Reproduce
./samples/react
and go to http://localhost:3000/styleguide/custom-route-type for example../src/AppRoot.js
-window.debug1 = SitecoreContextFactory;
- for debugging purpose laterThis has to update
headline
property's value that should effect our page's tittle. But it does not.However if you change
<SitecoreContextReactContext.Provider value={this.contextFactory}>
to<SitecoreContextReactContext.Provider value={Object.assign( Object.create( Object.getPrototypeOf(this.contextFactory)), this.contextFactory)}>
it will work fine.Possible Fix
We have to use React best practice and pass simple objects to Provider value, like this.contextFactory.context
Your Environment
The text was updated successfully, but these errors were encountered: